}
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)
/* 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;
}