typedef struct
{
int fd; /* FD we talk about. */
- int server_fd; /* Server FD for this connection. */
+ int server_fd;/* Server FD for this connection. */
int dir; /* Inbound/Outbound, maybe given implicit? */
void *data; /* Handler-specific data. */
void *tag; /* ID from the user for gpgme_remove_io_callback. */
+ char server_fd_str[15]; /* Same as SERVER_FD but as a string. We
+ need this because _gpgme_io_fdstr can't
+ be used on a closed descriptor. */
} iocb_data_t;
gpgsm->input_cb.dir = 0;
gpgsm->input_cb.tag = 0;
gpgsm->input_cb.server_fd = -1;
+ *gpgsm->input_cb.server_fd_str = 0;
gpgsm->output_cb.fd = -1;
gpgsm->output_cb.dir = 1;
gpgsm->output_cb.tag = 0;
gpgsm->output_cb.server_fd = -1;
+ *gpgsm->output_cb.server_fd_str = 0;
gpgsm->message_cb.fd = -1;
gpgsm->message_cb.dir = 0;
gpgsm->message_cb.tag = 0;
gpgsm->message_cb.server_fd = -1;
+ *gpgsm->message_cb.server_fd_str = 0;
gpgsm->status.fnc = 0;
gpgsm->colon.fnc = 0;
}
gpgsm->input_cb.fd = fds[1];
gpgsm->input_cb.server_fd = fds[0];
+ _gpgme_io_fd2str (gpgsm->input_cb.server_fd_str,
+ sizeof gpgsm->input_cb.server_fd_str,
+ gpgsm->input_cb.server_fd);
if (_gpgme_io_pipe (fds, 1) < 0)
{
}
gpgsm->output_cb.fd = fds[0];
gpgsm->output_cb.server_fd = fds[1];
+ _gpgme_io_fd2str (gpgsm->output_cb.server_fd_str,
+ sizeof gpgsm->output_cb.server_fd_str,
+ gpgsm->output_cb.server_fd);
if (_gpgme_io_pipe (fds, 0) < 0)
{
}
gpgsm->message_cb.fd = fds[1];
gpgsm->message_cb.server_fd = fds[0];
+ _gpgme_io_fd2str (gpgsm->message_cb.server_fd_str,
+ sizeof gpgsm->message_cb.server_fd_str,
+ gpgsm->message_cb.server_fd);
child_fds[0] = gpgsm->input_cb.server_fd;
child_fds[1] = gpgsm->output_cb.server_fd;
char *which;
iocb_data_t *iocb_data;
int dir;
- int fd;
switch (fd_type)
{
goto leave_set_fd;
}
}
-#endif
-
- fd = iocb_data->server_fd;
-#if USE_DESCRIPTOR_PASSING
- err = assuan_sendfd (gpgsm->assuan_ctx, fd);
+ err = assuan_sendfd (gpgsm->assuan_ctx, iocb_data->server_fd);
if (err)
goto leave_set_fd;
- _gpgme_io_close (fd);
+ _gpgme_io_close (iocb_data->server_fd);
+ iocb_data->server_fd = -1;
if (opt)
snprintf (line, COMMANDLINELEN, "%s FD %s", which, opt);
snprintf (line, COMMANDLINELEN, "%s FD", which);
#else
if (opt)
- snprintf (line, COMMANDLINELEN, "%s FD=%i %s", which, fd, opt);
+ snprintf (line, COMMANDLINELEN, "%s FD=%s %s",
+ which, iocb_data->server_fd_str, opt);
else
- snprintf (line, COMMANDLINELEN, "%s FD=%i", which, fd);
+ snprintf (line, COMMANDLINELEN, "%s FD=%s",
+ which, iocb_data->server_fd_str);
#endif
err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, line, NULL, NULL);
if (err)
{
_gpgme_io_close (iocb_data->fd);
- _gpgme_io_close (iocb_data->server_fd);
iocb_data->fd = -1;
- iocb_data->server_fd = -1;
+ if (iocb_data->server_fd != -1)
+ {
+ _gpgme_io_close (iocb_data->server_fd);
+ iocb_data->server_fd = -1;
+ }
}
#endif