|
|
|
@ -190,6 +190,35 @@ static int __conn_write(conn_t *co, void *buf, size_t buf_len)
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int _sntll_writemsg(conn_t *co, sxmsg_t *msg)
|
|
|
|
|
{
|
|
|
|
|
sntllv2_head_t *head;
|
|
|
|
|
size_t rd;
|
|
|
|
|
int r;
|
|
|
|
|
|
|
|
|
|
if(!co || !msg) return SNE_FAILED;
|
|
|
|
|
|
|
|
|
|
/* check message for validity */
|
|
|
|
|
head = &msg->mhead;
|
|
|
|
|
if(head->payload_length && !msg->payload) return SNE_FAILED;
|
|
|
|
|
|
|
|
|
|
/* write the head and payload if applicable */
|
|
|
|
|
pthread_mutex_lock(&co->sslinout[2]);
|
|
|
|
|
rd = __conn_write(co, head, sizeof(sntllv2_head_t));
|
|
|
|
|
if(rd < 0) {
|
|
|
|
|
co->flags |= SNSX_CLOSED;
|
|
|
|
|
r = SNE_ESSL;
|
|
|
|
|
} else if(head->payload_length) rd = __conn_write(co, msg->payload, head->payload_length);
|
|
|
|
|
/* check up again */
|
|
|
|
|
if(rd < 0) {
|
|
|
|
|
co->flags |= SNSX_CLOSED;
|
|
|
|
|
r = SNE_ESSL;
|
|
|
|
|
}
|
|
|
|
|
pthread_mutex_unlock(&co->sslinout[2]);
|
|
|
|
|
|
|
|
|
|
return r;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static sntllv2_bundle_t *__sntll_bundle_create(conn_t *co)
|
|
|
|
|
{
|
|
|
|
|
sntllv2_bundle_t *n = malloc(sizeof(sntllv2_bundle_t));
|
|
|
|
|