+ 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) != 0)
+ goto exit;
+ /* write uint16_t DSI request ID */
+ if (writet(obj->ipc_fd, &dsi->header.dsi_requestID, 2, 0, 2) != 2) {
+ LOG(log_error, logtype_afpd, "afp_disconnect: couldn't send DSI request ID");
+ goto exit;
+ }
+ /* 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 sends us SIGTERM because our session */
+ /* has been transfered to a old disconnected session, or we continue */
+ 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);