writemsg added;
This commit is contained in:
		
							parent
							
								
									2868ee8f95
								
							
						
					
					
						commit
						847ce7b54e
					
				| @ -1,6 +1,9 @@ | |||||||
| #ifndef __SNTLL_INTERNAL_H__ | #ifndef __SNTLL_INTERNAL_H__ | ||||||
| #define __SNTLL_INTERNAL_H__ | #define __SNTLL_INTERNAL_H__ | ||||||
| 
 | 
 | ||||||
|  | /* link related */ | ||||||
|  | int _sntll_writemsg(conn_t *co, sxmsg_t *msg); | ||||||
|  | 
 | ||||||
| /* channel operations */ | /* channel operations */ | ||||||
| uint8_t _channel_open(conn_t *co, uint16_t *chid); | uint8_t _channel_open(conn_t *co, uint16_t *chid); | ||||||
| uint8_t _channel_close(conn_t *co, uint16_t chid); | uint8_t _channel_close(conn_t *co, uint16_t chid); | ||||||
|  | |||||||
| @ -190,6 +190,35 @@ static int __conn_write(conn_t *co, void *buf, size_t buf_len) | |||||||
|   return r; |   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) | static sntllv2_bundle_t *__sntll_bundle_create(conn_t *co) | ||||||
| { | { | ||||||
|   sntllv2_bundle_t *n = malloc(sizeof(sntllv2_bundle_t)); |   sntllv2_bundle_t *n = malloc(sizeof(sntllv2_bundle_t)); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user