Changeset 34:0e2b57789361 in freeDiameter for freeDiameter/peers.c
- Timestamp:
- Oct 30, 2009, 5:23:06 PM (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
freeDiameter/peers.c
r33 r34 78 78 CHECK_FCT( fd_fifo_new(&p->p_events) ); 79 79 CHECK_FCT( fd_fifo_new(&p->p_tosend) ); 80 fd_list_init(&p->p_sentreq, p); 80 fd_list_init(&p->p_sr.srs, p); 81 CHECK_POSIX( pthread_mutex_init(&p->p_sr.mtx, NULL) ); 81 82 82 83 return 0; … … 180 181 } 181 182 183 /* Empty the lists of p_tosend and p_sentreq messages */ 184 void fd_peer_failover_msg(struct fd_peer * peer) 185 { 186 struct msg *m; 187 TRACE_ENTRY("%p", peer); 188 CHECK_PARAMS_DO(CHECK_PEER(peer), return); 189 190 /* Requeue all messages in the "out" queue */ 191 while ( fd_fifo_tryget(peer->p_tosend, &m) == 0 ) { 192 CHECK_FCT_DO(fd_fifo_post(fd_g_outgoing, &m), 193 /* fallback: destroy the message */ 194 CHECK_FCT_DO(fd_msg_free(m), /* What can we do more? */)); 195 } 196 197 /* Requeue all routable sent requests */ 198 fd_p_sr_failover(&peer->p_sr); 199 200 /* Done */ 201 return; 202 } 203 182 204 /* Destroy a structure once all cleanups have been performed */ 183 205 int fd_peer_free(struct fd_peer ** ptr) … … 197 219 free_null(p->p_hdr.info.pi_realm); 198 220 free_list( &p->p_hdr.info.pi_endpoints ); 199 /* Assume the security data is already freed */221 TODO("Free the security data if any ?"); 200 222 free_null(p->p_hdr.info.pi_prodname); 201 223 free_list( &p->p_hdr.info.pi_apps ); … … 214 236 215 237 CHECK_FCT( fd_thr_term(&p->p_outthr) ); 216 while ( fd_fifo_tryget(p->p_tosend, &t) == 0 ) {217 struct msg * m = t;218 TRACE_DEBUG(FULL, "Found message %p in outgoing queue of peer %p being destroyed, requeue", m, p);219 /* We simply requeue in global, the routing thread will re-handle it. */220 CHECK_FCT(fd_fifo_post(fd_g_outgoing, &m));221 }222 CHECK_FCT( fd_fifo_del(&p->p_tosend) );223 224 while (!FD_IS_LIST_EMPTY(&p->p_sentreq)) {225 struct sentreq * sr = (struct sentreq *)(p->p_sentreq.next);226 fd_list_unlink(&sr->chain);227 TRACE_DEBUG(FULL, "Found message %p in list of sent requests to peer %p being destroyed, requeue (fallback)", sr->req, p);228 CHECK_FCT(fd_fifo_post(fd_g_outgoing, &sr->req));229 free(sr);230 }231 238 232 239 if (p->p_cnxctx) { … … 234 241 } 235 242 243 /* Requeue any remaining message into global structures if possible */ 244 fd_peer_failover_msg(p); 245 CHECK_FCT_DO( fd_fifo_del(&p->p_tosend), /* continue */ ); 246 CHECK_POSIX_DO( pthread_mutex_destroy(&p->p_sr.mtx), /* continue */); 247 248 /* If the callback is still around... */ 236 249 if (p->p_cb) 237 250 (*p->p_cb)(NULL, p->p_cb_data); 238 251 252 /* Free the structure */ 239 253 free(p); 240 241 254 return 0; 242 255 }
Note: See TracChangeset
for help on using the changeset viewer.