|
|
|
@ -495,11 +495,16 @@ static void *__sntll_thread(void *b)
|
|
|
|
|
if(rd < 0) goto __sslproto_error;
|
|
|
|
|
else pthread_mutex_unlock(&(co->sslinout[0]));
|
|
|
|
|
if(rd != mhead->payload_length) {
|
|
|
|
|
mid = mhead->msgid;
|
|
|
|
|
/* if we're need to do something */
|
|
|
|
|
if(mhead->msgid >= 1024) {
|
|
|
|
|
mhead->opcode = SNE_INVALINDEX;
|
|
|
|
|
goto __return_error;
|
|
|
|
|
} else msg = co->messages[mhead->msgid];
|
|
|
|
|
} else {
|
|
|
|
|
pthread_mutex_lock(&co->idx_msg_lock);
|
|
|
|
|
msg = co->messages[mid];
|
|
|
|
|
pthread_mutex_unlock(&co->idx_msg_lock);
|
|
|
|
|
}
|
|
|
|
|
if(!msg) {
|
|
|
|
|
if(mhead->attr & SXMSG_OPEN) mhead->opcode = SNE_BADPROTO;
|
|
|
|
|
else {
|
|
|
|
@ -541,7 +546,9 @@ static void *__sntll_thread(void *b)
|
|
|
|
|
goto __again;
|
|
|
|
|
}
|
|
|
|
|
mid = mhead->msgid;
|
|
|
|
|
pthread_mutex_lock(&co->idx_msg_lock);
|
|
|
|
|
msg = co->messages[mid];
|
|
|
|
|
pthread_mutex_unlock(&co->idx_msg_lock);
|
|
|
|
|
if(!msg) goto __inval_idx_nor;
|
|
|
|
|
|
|
|
|
|
/* ok now we'are copy data and unlock wait mutex */
|
|
|
|
@ -575,7 +582,8 @@ static void *__sntll_thread(void *b)
|
|
|
|
|
else goto __again;
|
|
|
|
|
}
|
|
|
|
|
/* if message is busy - fails */
|
|
|
|
|
msg = co->messages[mhead->msgid];
|
|
|
|
|
mid = mhead->msgid;
|
|
|
|
|
msg = co->messages[mid];
|
|
|
|
|
if(msg) { mhead->opcode = SNE_EBUSY; goto __ret_regerr; }
|
|
|
|
|
|
|
|
|
|
/* now we will take a deal */
|
|
|
|
@ -591,10 +599,9 @@ static void *__sntll_thread(void *b)
|
|
|
|
|
if(mhead->payload_length) msg->payload = bbuf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mid = mhead->msgid;
|
|
|
|
|
pthread_mutex_lock(&co->idx_msg_lock);
|
|
|
|
|
idx_reserve(&co->idx_msg, mid);
|
|
|
|
|
co->messages[mhead->msgid] = msg;
|
|
|
|
|
co->messages[mid] = msg;
|
|
|
|
|
pthread_mutex_unlock(&co->idx_msg_lock);
|
|
|
|
|
|
|
|
|
|
/* now we are able to process the message */
|
|
|
|
@ -602,13 +609,15 @@ static void *__sntll_thread(void *b)
|
|
|
|
|
} else if(mhead->attr & SXMSG_CLOSED) {
|
|
|
|
|
/* check for the message */
|
|
|
|
|
if(mhead->msgid >= 1024) goto __inval_idx_nor;
|
|
|
|
|
msg = co->messages[mhead->msgid];
|
|
|
|
|
if(!msg) goto __inval_idx_nor;
|
|
|
|
|
mid = mhead->msgid;
|
|
|
|
|
pthread_mutex_lock(&co->idx_msg_lock);
|
|
|
|
|
msg = co->messages[mid];
|
|
|
|
|
if(!msg) {
|
|
|
|
|
pthread_mutex_unlock(&co->idx_msg_lock); goto __inval_idx_nor; }
|
|
|
|
|
|
|
|
|
|
/* message dialog is closed - remove this right now */
|
|
|
|
|
pthread_mutex_lock(&co->idx_msg_lock);
|
|
|
|
|
idx_free(&co->idx_msg, mhead->msgid);
|
|
|
|
|
co->messages[mhead->msgid] = NULL;
|
|
|
|
|
idx_free(&co->idx_msg, mid);
|
|
|
|
|
co->messages[mid] = NULL;
|
|
|
|
|
pthread_mutex_unlock(&co->idx_msg_lock);
|
|
|
|
|
|
|
|
|
|
if(msg->mhead.attr & SXMSG_TIMEDOUT) { /* nobody wait for it */
|
|
|
|
@ -630,13 +639,14 @@ static void *__sntll_thread(void *b)
|
|
|
|
|
(mhead->attr & SXMSG_REPLYREQ)) { /* ongoing dialog */
|
|
|
|
|
/* check for the message */
|
|
|
|
|
if(mhead->msgid >= 1024) goto __inval_idx_nor;
|
|
|
|
|
msg = co->messages[mhead->msgid];
|
|
|
|
|
mid = mhead->msgid;
|
|
|
|
|
msg = co->messages[mid];
|
|
|
|
|
if(!msg) goto __inval_idx_nor;
|
|
|
|
|
|
|
|
|
|
if(msg->mhead.attr & SXMSG_TIMEDOUT) { /* nobody wait for it */
|
|
|
|
|
pthread_mutex_lock(&co->idx_msg_lock);
|
|
|
|
|
idx_free(&co->idx_msg, mhead->msgid);
|
|
|
|
|
co->messages[mhead->msgid] = NULL;
|
|
|
|
|
idx_free(&co->idx_msg, mid);
|
|
|
|
|
co->messages[mid] = NULL;
|
|
|
|
|
pthread_mutex_unlock(&co->idx_msg_lock);
|
|
|
|
|
|
|
|
|
|
/* now just free it */
|
|
|
|
|