Changeset 7447
- Timestamp:
- 09/17/12 12:35:53 (12 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/global-functions.h
r7439 r7447 69 69 extern int32_t accept_connection(int32_t i, int32_t j); 70 70 extern void start_thread(void * startroutine, char * nameroutine); 71 extern voidadd_job(struct s_client *cl, int8_t action, void *ptr, int32_t len);71 extern int32_t add_job(struct s_client *cl, int8_t action, void *ptr, int32_t len); 72 72 extern void add_check(struct s_client *client, int8_t action, void *ptr, int32_t size, int32_t ms_delay); 73 73 extern int32_t reader_init(struct s_reader *); -
trunk/oscam-llist.c
r7426 r7447 560 560 } 561 561 562 LLIST *ll_clone(LLIST *l, uint32_t copysize) 563 { 564 if (!l||l->flag) return NULL; 565 566 LLIST *clone = ll_create(l->lock.name); 567 LL_LOCKITER *li = ll_li_create(l, 0); 568 void *data, *new_data; 569 while ((data=ll_li_next(li))) { 570 new_data = cs_malloc(&new_data, copysize, 0); 571 memcpy(new_data, data, copysize); 572 ll_append_nolock(clone, new_data); 573 } 574 ll_li_destroy(li); 575 return clone; 576 } -
trunk/oscam-llist.h
r7426 r7447 49 49 LL_NODE *ll_prepend(LLIST *l, void *obj); // prepend obj to llist 50 50 51 //clones a list, duplicates data 52 LLIST *ll_clone(LLIST *l, uint32_t copysize); 53 51 54 //New type of lock, list is locked during iterate! create=lock, destroy=unlock 52 55 LL_LOCKITER *ll_li_create(LLIST *l, int32_t writelock); -
trunk/oscam.c
r7445 r7447 593 593 { 594 594 if (data) { 595 if (data->len && data->ptr) 595 if (data->len && data->ptr) { 596 if (data->action == ACTION_CACHE_PUSH_OUT) { 597 ECM_REQUEST *er = data->ptr; 598 ll_destroy(er->csp_lastnodes); 599 er->csp_lastnodes = NULL; 600 } 596 601 free(data->ptr); 602 } 597 603 free(data); 598 604 } … … 1843 1849 ECM_REQUEST *erc = cs_malloc(&erc, sizeof(ECM_REQUEST), 0); 1844 1850 memcpy(erc, er, sizeof(ECM_REQUEST)); 1845 add_job(cl, ACTION_CACHE_PUSH_OUT, erc, sizeof(ECM_REQUEST)); 1851 erc->csp_lastnodes = ll_clone(er->csp_lastnodes, 8); //because er could be disposed before erc is processed, duplicate csp nodes. solves deadlocks 1852 if (!add_job(cl, ACTION_CACHE_PUSH_OUT, erc, sizeof(ECM_REQUEST))) 1853 ll_destroy(erc->csp_lastnodes); 1846 1854 } 1847 1855 … … 4151 4159 res = ph[cl->ctyp].c_cache_push(cl, er); 4152 4160 } 4153 4154 4161 debug_ecm(D_CACHEEX, "pushed ECM %s to %s res %d stats %d", buf, username(cl), res, stats); 4155 4162 … … 4199 4206 * else set size to 0 4200 4207 **/ 4201 voidadd_job(struct s_client *cl, int8_t action, void *ptr, int32_t len) {4208 int32_t add_job(struct s_client *cl, int8_t action, void *ptr, int32_t len) { 4202 4209 4203 4210 if (!cl || cl->kill) { 4204 4211 if (!cl) cs_log("WARNING: add_job failed."); //Ignore jobs for killed clients 4205 4212 if (len && ptr) free(ptr); 4206 return ;4213 return 0; 4207 4214 } 4208 4215 … … 4225 4232 } 4226 4233 pthread_mutex_unlock(&cl->thread_lock); 4227 return ;4234 return 0; 4228 4235 } 4229 4236 … … 4231 4238 if (!data && len && ptr) { 4232 4239 free(ptr); 4233 return ;4240 return 0; 4234 4241 } 4235 4242 … … 4250 4257 pthread_mutex_unlock(&cl->thread_lock); 4251 4258 cs_debug_mask(D_TRACE, "add %s job action %d queue length %d %s", action > ACTION_CLIENT_FIRST ? "client" : "reader", action, ll_count(cl->joblist), username(cl)); 4252 return ;4259 return 1; 4253 4260 } 4254 4261 … … 4275 4282 cl->thread_active = 1; 4276 4283 pthread_mutex_unlock(&cl->thread_lock); 4284 return 1; 4277 4285 } 4278 4286
Note:
See TracChangeset
for help on using the changeset viewer.