/*****************************************************************************/ void
libipm_msg_in_close_file_descriptors(struct trans *self)
{ struct libipm_priv *priv = (struct libipm_priv *)self->extra_data; if (priv != NULL)
{ unsignedint i; for (i = priv->in_fd_index ; i < priv->in_fd_count; ++i)
{
g_file_close(priv->in_fds[i]);
}
priv->in_fd_count = 0;
priv->in_fd_index = 0;
}
}
/**************************************************************************//**
* Send function for a struct trans initialised with libipm_init_trans()
*
* @param self Transport to send on
* @param data pointer to data to send
* @param len Length of data to send
* @return As for write(2)
*/ staticint
libipm_trans_send_proc(struct trans *self, constchar *data, int len)
{ int rv; struct libipm_priv *priv = (struct libipm_priv *)self->extra_data; if (priv != NULL && data == self->out_s->data)
{ /* We're sending the message header. Send any file descriptors
* as ancillary data */
rv = g_sck_send_fd_set(self->sck, data, len,
priv->out_fds, priv->out_fd_count);
} else
{
rv = g_sck_send(self->sck, data, len, 0);
}
return rv;
}
/**************************************************************************//**
* Receive function for a struct trans initialised with libipm_init_trans()
*
* @param self Transport to receive on
* @param data pointer to receive data buffer
* @param len Length of data to read
* @return As for read(2)
*/ staticint
libipm_trans_recv_proc(struct trans *self, char *data, int len)
{ int rv; struct libipm_priv *priv = (struct libipm_priv *)self->extra_data; if (priv != NULL && data == self->in_s->data)
{ /* We're receiving the message header */ unsignedint fdcount;
/* Check there are no live file descriptors in the input *bufferfromapreviousmessage.Thisshouldn'thappen,but
* if by some chance it does, we could leak file descriptors */ if (priv->in_fd_count > 0)
{
LOG(LOG_LEVEL_WARNING, "Unconsumed file descriptors detected");
libipm_msg_in_close_file_descriptors(self);
}
rv = g_sck_recv_fd_set(self->sck, data, len,
priv->in_fds, MAX_FD_PER_MSG,
&fdcount); if (fdcount > MAX_FD_PER_MSG)
{
LOG(LOG_LEVEL_WARNING, "%d file descriptors were discarded on recvmsg()",
fdcount - MAX_FD_PER_MSG);
fdcount = MAX_FD_PER_MSG;
}
priv->in_fd_count = fdcount;
} else
{
rv = g_sck_recv(self->sck, data, len, 0);
}
return rv;
}
/**************************************************************************//**
* Destructor for a struct trans initialised with libipm_init_trans()
*
* @param trans Transport to destroy
*/ staticvoid
libipm_trans_destructor(struct trans *trans)
{ struct libipm_priv *priv = (struct libipm_priv *)trans->extra_data;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.