X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=etc%2Fafpd%2Fauth.c;h=e63a5a42c8bd8923aeb0d951e6520458809f52ec;hb=f357762920325c7d84ec891e468655fea5b4473e;hp=2b1a99d77b92ae6bf1beac540fb2aa854b2f4426;hpb=91861018b32aa58a088f34c075fb63201cc15b71;p=netatalk.git diff --git a/etc/afpd/auth.c b/etc/afpd/auth.c index 2b1a99d7..e63a5a42 100644 --- a/etc/afpd/auth.c +++ b/etc/afpd/auth.c @@ -635,6 +635,11 @@ int afp_disconnect(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, } LOG(log_note, logtype_afpd, "afp_disconnect: trying primary reconnect"); + dsi->flags |= DSI_RECONINPROG; + + /* Deactivate tickle timer */ + const struct itimerval none = {{0, 0}, {0, 0}}; + setitimer(ITIMER_REAL, &none, NULL); /* check for old session, possibly transfering session from here to there */ if (ipc_child_write(obj->ipc_fd, IPC_DISCOLDSESSION, tklen, &token) == -1) @@ -647,11 +652,21 @@ int afp_disconnect(AFPObj *obj, char *ibuf, size_t ibuflen _U_, char *rbuf _U_, /* now send our connected AFP client socket */ if (send_fd(obj->ipc_fd, dsi->socket) != 0) goto exit; - /* Now see what happens: either afpd master kills us because our session */ + /* Now see what happens: either afpd master sends us SIGTERM because our session */ /* has been transfered to a old disconnected session, or we continue */ - sleep(2); + sleep(5); + + if (!(dsi->flags & DSI_RECONINPROG)) { /* deleted in SIGTERM handler */ + /* Reconnect succeeded, we exit now after sleeping some more */ + sleep(2); /* sleep some more to give the recon. session time */ + LOG(log_note, logtype_afpd, "afp_disconnect: primary reconnect succeeded"); + exit(0); + } exit: + /* Reinstall tickle timer */ + setitimer(ITIMER_REAL, &dsi->timer, NULL); + LOG(log_error, logtype_afpd, "afp_disconnect: primary reconnect failed"); return AFPERR_MISC; }