+ uint16_t dsiID;
+ int socket;
+ DSI *dsi = (DSI *)AFPobj->handle;
+
+ LOG(log_debug, logtype_afpd, "afp_dsi_transfer_session: got SIGURG, trying to receive session");
+
+ if (readt(AFPobj->ipc_fd, &dsiID, 2, 0, 2) != 2) {
+ LOG(log_error, logtype_afpd, "afp_dsi_transfer_session: couldn't receive DSI id, goodbye");
+ afp_dsi_close(AFPobj);
+ exit(EXITERR_SYS);
+ }
+
+ if ((socket = recv_fd(AFPobj->ipc_fd, 1)) == -1) {
+ LOG(log_error, logtype_afpd, "afp_dsi_transfer_session: couldn't receive session fd, goodbye");
+ afp_dsi_close(AFPobj);
+ exit(EXITERR_SYS);
+ }
+
+ LOG(log_debug, logtype_afpd, "afp_dsi_transfer_session: received socket fd: %i", socket);
+
+ dsi->proto_close(dsi);
+ dsi->socket = socket;
+ dsi->flags = DSI_RECONSOCKET;
+ dsi->datalen = 0;
+ dsi->eof = dsi->start = dsi->buffer;
+ dsi->in_write = 0;
+ dsi->header.dsi_requestID = dsiID;
+ dsi->header.dsi_command = DSIFUNC_CMD;
+
+ /*
+ * The session transfer happens in the middle of FPDisconnect old session, thus we
+ * have to send the reply now.
+ */
+ if (!dsi_cmdreply(dsi, AFP_OK)) {
+ LOG(log_error, logtype_afpd, "dsi_cmdreply: %s", strerror(errno) );
+ afp_dsi_close(AFPobj);
+ exit(EXITERR_CLNT);
+ }
+
+ LOG(log_note, logtype_afpd, "afp_dsi_transfer_session: succesfull primary reconnect");
+ /*
+ * Now returning from this signal handler return to dsi_receive which should start
+ * reading/continuing from the connected socket that was passed via the parent from
+ * another session. The parent will terminate that session.
+ */
+ siglongjmp(recon_jmp, 1);