-
- /* killed old session, not easy */
- server_ipc_write(IPC_KILLTOKEN, tklen, &token);
- sleep(1);
-
- return AFPERR_SESSCLOS; /* was AFP_OK */
+
+ LOG(log_note, logtype_afpd, "afp_disconnect: trying primary reconnect");
+
+ /* check for old session, possibly transfering session from here to there */
+ if (ipc_child_write(obj->ipc_fd, IPC_DISCOLDSESSION, tklen, &token) == -1)
+ 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 kills us because our session */
+ /* has been transfered to a old disconnected session, or we continue */
+ sleep(2);
+
+exit:
+ LOG(log_error, logtype_afpd, "afp_disconnect: primary reconnect failed");
+ return AFPERR_MISC;