Changeset 1014:908ffbb81f60 in freeDiameter for libfdcore/p_sr.c
- Timestamp:
- Mar 29, 2013, 6:30:59 PM (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdcore/p_sr.c
r974 r1014 85 85 } 86 86 87 struct expire_data { 88 struct msg * request; 89 struct fd_peer * sentto; 90 }; 91 87 92 /* (detached) thread that calls the anscb on expired messages. 88 93 We do it in a separate thread to avoid blocking the reception of new messages during this time */ 89 static void * call_ anscb_expire(void * arg) {90 struct msg * expired_req= arg;91 92 void (* anscb)(void *, struct msg **);94 static void * call_expirecb(void * arg) { 95 struct expire_data * ed = arg; 96 97 void (*expirecb)(void *, DiamId_t, size_t, struct msg **); 93 98 void * data; 94 99 … … 103 108 104 109 /* Retrieve callback in the message */ 105 CHECK_FCT_DO( fd_msg_anscb_get( e xpired_req, &anscb, &data ), return NULL);106 ASSERT( anscb);110 CHECK_FCT_DO( fd_msg_anscb_get( ed->request, NULL, &expirecb, &data ), return NULL); 111 ASSERT(expirecb); 107 112 108 113 /* Clean up this data from the message */ 109 CHECK_FCT_DO( fd_msg_anscb_associate( e xpired_req, NULL, NULL, NULL ), return NULL);114 CHECK_FCT_DO( fd_msg_anscb_associate( ed->request, NULL, NULL, NULL, NULL ), return NULL); 110 115 111 116 /* Call it */ 112 (* anscb)(data, &expired_req);117 (*expirecb)(data, ed->sentto->p_hdr.info.pi_diamid, ed->sentto->p_hdr.info.pi_diamidlen, &ed->request); 113 118 114 119 /* If the callback did not dispose of the message, do it now */ 115 if (expired_req) { 116 fd_msg_log(FD_MSG_LOG_DROPPED, expired_req, "Expiration period completed without an answer, and the expiry callback did not dispose of the message."); 117 CHECK_FCT_DO( fd_msg_free(expired_req), /* ignore */ ); 118 } 120 if (ed->request) { 121 fd_msg_log(FD_MSG_LOG_DROPPED, ed->request, "Expiration period completed without an answer, and the expiry callback did not dispose of the message."); 122 CHECK_FCT_DO( fd_msg_free(ed->request), /* ignore */ ); 123 } 124 125 free(ed); 119 126 120 127 /* Finish */ … … 125 132 static void * sr_expiry_th(void * arg) { 126 133 struct sr_list * srlist = arg; 127 struct msg * expired_req;128 134 pthread_attr_t detached; 135 struct expire_data * ed; 129 136 130 137 TRACE_ENTRY("%p", arg); … … 177 184 178 185 /* Now, the first request in the list is expired; remove it and call the anscb for it in a new thread */ 186 CHECK_MALLOC_DO( ed = malloc(sizeof(struct expire_data)), goto error ); 187 ed->sentto = first->chain.head->o; 188 ed->request = first->req; 179 189 fd_list_unlink(&first->chain); 180 190 fd_list_unlink(&first->expire); 181 expired_req = first->req;182 191 free(first); 183 192 184 CHECK_POSIX_DO( pthread_create( &th, &detached, call_ anscb_expire, expired_req), goto error );193 CHECK_POSIX_DO( pthread_create( &th, &detached, call_expirecb, ed ), goto error ); 185 194 186 195 /* loop */
Note: See TracChangeset
for help on using the changeset viewer.