Skip to content

Commit

Permalink
issue error when database has gone away (#879)
Browse files Browse the repository at this point in the history
TODO: postgresql doesn't automatically reconnect
  • Loading branch information
pjstevns committed Feb 1, 2011
1 parent e61abde commit 901e5ec
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lmtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ void send_greeting(ClientSession_t *session)
{
field_t banner;
GETCONFIGVALUE("banner", "LMTP", banner);
if (! dm_db_ping()) {
ci_write(session->ci, "500 database has gone fishing BYE\r\n");
session->state = QUIT;
return;
}

if (strlen(banner) > 0)
ci_write(session->ci, "220 %s %s\r\n", session->hostname, banner);
else
Expand Down
6 changes: 6 additions & 0 deletions src/pop3.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ static void send_greeting(ClientSession_t *session)
{
field_t banner;
GETCONFIGVALUE("banner", "POP", banner);
if (! dm_db_ping()) {
ci_write(session->ci, "+ERR database has gone fishing\r\n");
session->state = CLIENTSTATE_QUIT;
return;
}

if (strlen(banner) > 0) {
ci_write(session->ci, "+OK %s %s\r\n", banner, session->apop_stamp);
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/timsieve.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ static void send_greeting(ClientSession_t *session)
{
field_t banner;
GETCONFIGVALUE("banner", "SIEVE", banner);
if (! dm_db_ping()) {
ci_write(session->ci, "BYE \"database has gone fishing\"\r\n");
session->state = QUIT;
return;
}

if (strlen(banner) > 0)
ci_write(session->ci, "\"IMPLEMENTATION\" \"%s\"\r\n", banner);
else
Expand Down

0 comments on commit 901e5ec

Please sign in to comment.