Changeset 688:8c3dc8584dab in freeDiameter for libfdcore
- Timestamp:
- Jan 19, 2011, 7:05:30 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libfdcore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdcore/core.c
r686 r688 195 195 fd_g_config = &g_conf; 196 196 CHECK_FCT( fd_conf_init() ); 197 198 /* Initialize the message logging facility */ 199 ml_conf_init(fd_g_config->cnf_dict); 197 200 198 201 /* Add definitions of the base protocol */ -
libfdcore/messages.c
r658 r688 313 313 return ret; 314 314 315 fd_log_debug("The following message does not comply to the dictionary and/or rules (%s):\n", pei.pei_errcode);316 fd_msg_dump_walk( NONE, m);315 TRACE_DEBUG(INFO, "A message does not comply to the dictionary and/or rules (%s)", pei.pei_errcode); 316 fd_msg_dump_walk(FULL, m); 317 317 318 318 CHECK_FCT( fd_msg_hdr(m, &hdr) ); … … 364 364 365 365 /* Just discard */ 366 fd_msg_log( FD_MSG_LOG_DROPPED, m, "Answer not compliant to dictionary's ABNF (%s)", pei.pei_errcode ); 366 367 CHECK_FCT( fd_msg_free( m ) ); 367 368 *msg = NULL; -
libfdcore/p_ce.c
r662 r688 598 598 fd_cnx_destroy(recv_cnx); 599 599 if (*cer) { 600 fd_msg_log(FD_MSG_LOG_DROPPED, *cer, "An error occurred while rejecting a CER."); 600 601 fd_msg_free(*cer); 601 602 *cer = NULL; … … 665 666 if (req || (peer->p_hdr.info.runtime.pir_state != STATE_WAITCEA)) { 666 667 if (*msg) { 667 fd_log_debug("Received CER/CEA message while in state '%s', discarded.\n", STATE_STR(peer->p_hdr.info.runtime.pir_state)); 668 fd_msg_dump_walk(NONE, *msg); 668 fd_msg_log( FD_MSG_LOG_DROPPED, *msg, "Received CER/CEA while in '%s' state.\n", STATE_STR(peer->p_hdr.info.runtime.pir_state)); 669 669 CHECK_FCT_DO( fd_msg_free(*msg), /* continue */); 670 670 *msg = NULL; … … 911 911 cleanup: 912 912 if (msg) { 913 fd_msg_log(FD_MSG_LOG_DROPPED, msg, "An error occurred while processing a CER."); 913 914 fd_msg_free(msg); 914 915 } -
libfdcore/p_out.c
r662 r688 60 60 } 61 61 62 /* Log the message */63 if (TRACE_BOOL(FULL)) {64 CHECK_FCT_DO( fd_msg_update_length(*msg), /* continue */ );65 TRACE_DEBUG(FULL, "Sending the following message on connection '%s':", fd_cnx_getid(cnx));66 fd_msg_dump_walk(FULL, *msg);67 }68 69 62 /* Create the message buffer */ 70 63 CHECK_FCT(fd_msg_bufferize( *msg, &buf, &sz )); 71 64 pthread_cleanup_push( free, buf ); 65 66 /* Log the message */ 67 fd_msg_log( FD_MSG_LOG_SENT, *msg, "Sent to '%s'", fd_cnx_getid(cnx)); 72 68 73 69 /* Save a request before sending so that there is no race condition with the answer */ … … 93 89 struct msg *msg = arg; 94 90 CHECK_FCT_DO(fd_fifo_post(fd_g_outgoing, &msg), 95 CHECK_FCT_DO(fd_msg_free(msg), /* What can we do more? */)); 91 { 92 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "An error occurred while attempting to requeue this message during cancellation of the sending function"); 93 CHECK_FCT_DO(fd_msg_free(msg), /* What can we do more? */); 94 } ); 96 95 } 97 96 … … 112 111 while (1) { 113 112 struct msg * msg; 113 int ret; 114 114 115 115 /* Retrieve next message to send */ … … 120 120 121 121 /* Send the message, log any error */ 122 CHECK_FCT_DO( do_send(&msg, 0, peer->p_cnxctx, &peer->p_hbh, &peer->p_sr),122 CHECK_FCT_DO( ret = do_send(&msg, 0, peer->p_cnxctx, &peer->p_hbh, &peer->p_sr), 123 123 { 124 124 if (msg) { 125 fd_log_debug("An error occurred while sending this message, it was lost:\n"); 126 fd_msg_dump_walk(NONE, msg); 125 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Internal error: Problem while sending (%s)\n", strerror(ret) ); 127 126 fd_msg_free(msg); 128 127 } … … 151 150 152 151 } else { 152 int ret; 153 153 uint32_t *hbh = NULL; 154 154 … … 161 161 162 162 /* Do send the message */ 163 CHECK_FCT_DO( do_send(msg, flags, cnx, hbh, peer ? &peer->p_sr : NULL),163 CHECK_FCT_DO( ret = do_send(msg, flags, cnx, hbh, peer ? &peer->p_sr : NULL), 164 164 { 165 165 if (msg) { 166 fd_log_debug("An error occurred while sending this message, it was lost:\n"); 167 fd_msg_dump_walk(NONE, *msg); 166 fd_msg_log( FD_MSG_LOG_DROPPED, *msg, "Internal error: Problem while sending (%s)\n", strerror(ret) ); 168 167 fd_msg_free(*msg); 169 168 *msg = NULL; -
libfdcore/p_psm.c
r662 r688 166 166 case FDEVP_CNX_INCOMING: { 167 167 struct cnx_incoming * evd = ev->data; 168 fd_msg_log( FD_MSG_LOG_DROPPED, evd->cer, "Message discarded while cleaning peer state machine queue." ); 168 169 CHECK_FCT_DO( fd_msg_free(evd->cer), /* continue */); 169 170 fd_cnx_destroy(evd->cnx); … … 394 395 } ); 395 396 396 TRACE_DEBUG(FULL, "Received a message (%zdb) from '%s'", ev_sz, peer->p_hdr.info.pi_diamid); 397 if (TRACE_BOOL(FULL+1)) { 398 CHECK_FCT_DO( fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ), ); 399 fd_msg_dump_walk(FULL, msg); 400 } else { 401 fd_msg_dump_one(FULL, msg); 402 } 397 /* Log incoming message */ 398 fd_msg_log( FD_MSG_LOG_RECEIVED, msg, "Received %zdb from '%s'", ev_sz, peer->p_hdr.info.pi_diamid ); 403 399 404 400 /* Extract the header */ … … 411 407 CHECK_FCT_DO( fd_p_sr_fetch(&peer->p_sr, hdr->msg_hbhid, &req), goto psm_end ); 412 408 if (req == NULL) { 413 fd_log_debug("Received a Diameter answer message with no corresponding sent request, discarding.\n"); 414 fd_msg_dump_walk(NONE, msg); 409 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Answer received with no corresponding sent request." ); 415 410 fd_msg_free(msg); 416 411 goto psm_loop; … … 453 448 default: 454 449 /* In such case, just discard the message */ 455 fd_log_debug("Received a routable message while not in OPEN state from peer '%s', discarded.\n", peer->p_hdr.info.pi_diamid); 456 fd_msg_dump_walk(NONE, msg); 450 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Received from peer '%s' while connection was not in OPEN state.", peer->p_hdr.info.pi_diamid ); 457 451 fd_msg_free(msg); 458 452 } … … 468 462 if (msg) { 469 463 /* Send the error back to the peer */ 470 CHECK_FCT_DO( fd_out_send(&msg, NULL, peer, FD_CNX_ORDERED), /* In case of error the message has already been dumped */);464 CHECK_FCT_DO( ret = fd_out_send(&msg, NULL, peer, FD_CNX_ORDERED), ); 471 465 if (msg) { 466 /* Only if an error occurred & the message was not saved / dumped */ 467 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Internal error: Problem while sending (%s)\n", strerror(ret) ); 472 468 CHECK_FCT_DO( fd_msg_free(msg), goto psm_end); 473 469 } … … 498 494 default: 499 495 /* Unknown / unexpected / invalid message */ 500 fd_log_debug("Received an unknown local message from peer '%s', discarded.\n", peer->p_hdr.info.pi_diamid); 501 fd_msg_dump_walk(NONE, msg); 496 TRACE_DEBUG(INFO, "Invalid non-routable command received: %u.", hdr->msg_code); 502 497 if (hdr->msg_flags & CMD_FLAG_REQUEST) { 503 498 do { … … 518 513 /* Cleanup the message if not done */ 519 514 if (msg) { 515 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Received un-handled non-routable command from peer '%s'.", peer->p_hdr.info.pi_diamid ); 520 516 CHECK_FCT_DO( fd_msg_free(msg), /* continue */); 521 517 msg = NULL; … … 525 521 /* At this point the message must have been fully handled already */ 526 522 if (msg) { 527 fd_log_debug("Internal error: unhandled message (discarded)!\n"); 528 fd_msg_dump_walk(NONE, msg); 523 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Internal error: unhandled message.", peer->p_hdr.info.pi_diamid ); 529 524 fd_msg_free(msg); 530 525 } … … 602 597 } 603 598 if (params->cer) { 599 fd_msg_log( FD_MSG_LOG_DROPPED, params->cer, "Internal error: this CER was not handled as expected." ); 604 600 CHECK_FCT_DO( fd_msg_free(params->cer), ); 605 601 params->cer = NULL; -
libfdcore/p_sr.c
r662 r688 109 109 /* If the callback did not dispose of the message, do it now */ 110 110 if (expired_req) { 111 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."); 111 112 CHECK_FCT_DO( fd_msg_free(expired_req), /* ignore */ ); 112 113 } … … 296 297 if (fd_msg_is_routable(sr->req)) { 297 298 struct msg_hdr * hdr = NULL; 299 int ret; 298 300 299 301 /* Set the 'T' flag */ … … 303 305 304 306 /* Requeue for sending to another peer */ 305 CHECK_FCT_DO(fd_fifo_post(fd_g_outgoing, &sr->req), 306 CHECK_FCT_DO(fd_msg_free(sr->req), /* What can we do more? */)); 307 CHECK_FCT_DO( ret = fd_fifo_post(fd_g_outgoing, &sr->req), 308 { 309 fd_msg_log( FD_MSG_LOG_DROPPED, sr->req, "Internal error: error while requeuing during failover: %s", strerror(ret) ); 310 CHECK_FCT_DO(fd_msg_free(sr->req), /* What can we do more? */) 311 }); 307 312 } else { 308 /* Just free the request... */ 313 /* Just free the request. */ 314 fd_msg_log( FD_MSG_LOG_DROPPED, sr->req, "Local message discarded during failover" ); 309 315 CHECK_FCT_DO(fd_msg_free(sr->req), /* Ignore */); 310 316 } -
libfdcore/peers.c
r662 r688 211 211 while ( fd_fifo_tryget(peer->p_tosend, &m) == 0 ) { 212 212 CHECK_FCT_DO(fd_fifo_post(fd_g_outgoing, &m), 213 { 213 214 /* fallback: destroy the message */ 214 CHECK_FCT_DO(fd_msg_free(m), /* What can we do more? */)); 215 fd_msg_log(FD_MSG_LOG_DROPPED, m, "Internal error: unable to requeue this message during failover process"); 216 CHECK_FCT_DO(fd_msg_free(m), /* What can we do more? */) 217 } ); 215 218 } 216 219 -
libfdcore/queues.c
r686 r688 74 74 75 75 /* We got one! */ 76 fd_log_debug("The following message is lost because the daemon is stopping:\n"); 77 fd_msg_dump_walk(NONE, msg); 76 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Message lost because framework is terminating." ); 78 77 fd_msg_free(msg); 79 78 } -
libfdcore/routing_dispatch.c
r686 r688 409 409 410 410 if (!peer) { 411 TRACE_DEBUG(INFO, "Unable to send error '%s' to deleted peer '%s' in reply to:", error_code, id); 412 fd_msg_dump_walk(INFO, *pmsg); 411 fd_msg_log(FD_MSG_LOG_DROPPED, *pmsg, "Unable to send error '%s' to deleted peer '%s' in reply to this message.", error_code, id); 413 412 fd_msg_free(*pmsg); 414 413 *pmsg = NULL; … … 467 466 } 468 467 if (*pmsg) { /* another error happen'd */ 469 TRACE_DEBUG(INFO, "An unexpected error occurred (%s), discarding a message:", strerror(ret)); 470 fd_msg_dump_walk(INFO, *pmsg); 468 fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "An unexpected error occurred while parsing the message (%s)", strerror(ret)); 471 469 CHECK_FCT_DO( fd_msg_free(*pmsg), /* continue */); 472 470 *pmsg = NULL; … … 522 520 523 521 if (!is_req) { 524 TRACE_DEBUG(INFO, "Received an answer to a localy issued query, but no handler processed this answer!"); 525 fd_msg_dump_walk(INFO, *pmsg); 522 fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "Internal error: Answer received to locally issued request, but not handled by any handler."); 526 523 fd_msg_free(*pmsg); 527 524 *pmsg = NULL; … … 748 745 for ( li = (is_req ? rt_fwd_list.next : rt_fwd_list.prev) ; *pmsg && (li != &rt_fwd_list) ; li = (is_req ? li->next : li->prev) ) { 749 746 struct rt_hdl * rh = (struct rt_hdl *)li; 747 int ret; 750 748 751 749 if (is_req && (rh->dir > RT_FWD_ALL)) … … 756 754 /* Ok, call this cb */ 757 755 TRACE_DEBUG(ANNOYING, "Calling next FWD callback on %p : %p", *pmsg, rh->rt_fwd_cb); 758 CHECK_FCT_DO( (*rh->rt_fwd_cb)(rh->cbdata, pmsg),756 CHECK_FCT_DO( ret = (*rh->rt_fwd_cb)(rh->cbdata, pmsg), 759 757 { 760 TRACE_DEBUG(INFO, "A FWD routing callback returned an error, message discarded."); 761 fd_msg_dump_walk(INFO, *pmsg); 758 fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "Internal error: a FWD routing callback returned an error (%s)", strerror(ret)); 762 759 fd_msg_free(*pmsg); 763 760 *pmsg = NULL; … … 817 814 fd_cpu_flush_cache(); 818 815 if ((!peer) || (peer->p_hdr.info.runtime.pir_state != STATE_OPEN)) { 819 TRACE_DEBUG(INFO, "Unable to forward answer message to peer '%s', deleted or not in OPEN state.", qry_src); 820 fd_msg_dump_walk(INFO, *pmsg); 816 fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "Unable to forward answer to deleted / closed peer '%s'.", qry_src); 821 817 fd_msg_free(*pmsg); 822 818 *pmsg = NULL; … … 897 893 CHECK_FCT_DO( ret = (*rh->rt_out_cb)(rh->cbdata, *pmsg, candidates), 898 894 { 899 TRACE_DEBUG(INFO, "An OUT routing callback returned an error (%s) ! Message discarded.", strerror(ret)); 900 fd_msg_dump_walk(INFO, *pmsg); 895 fd_msg_log( FD_MSG_LOG_DROPPED, *pmsg, "Internal error: an OUT routing callback returned an error (%s)", strerror(ret)); 901 896 fd_msg_free(*pmsg); 902 897 *pmsg = NULL; … … 947 942 /* If the message has not been sent, return an error */ 948 943 if (*pmsg) { 949 TRACE_DEBUG(INFO, "Could not send the following message, replying with UNABLE_TO_DELIVER"); 950 fd_msg_dump_walk(INFO, *pmsg); 944 fd_msg_log( FD_MSG_LOG_NODELIVER, *pmsg, "No suitable candidate to route the message to." ); 951 945 return_error( pmsg, "DIAMETER_UNABLE_TO_DELIVER", "No suitable candidate to route the message to", NULL); 952 946 } -
libfdcore/server.c
r686 r688 143 143 CHECK_FCT_DO( fd_msg_parse_rules( msg, fd_g_config->cnf_dict, NULL ), /* Parsing failed -- trace details ? */ goto cleanup ); 144 144 145 fd_msg_dump_walk(FULL, msg);146 147 145 /* Now check we received a CER */ 148 146 CHECK_FCT_DO( fd_msg_hdr ( msg, &hdr ), goto fatal_error ); … … 164 162 CHECK_POSIX_DO( pthread_mutex_unlock(&s->clients_mtx), goto fatal_error ); 165 163 164 /* Cleanup the parsed message if any */ 165 if (msg) { 166 fd_msg_log( FD_MSG_LOG_DROPPED, msg, "Received invalid/unexpected message from connecting client '%s'", fd_cnx_getid(c->conn) ); 167 CHECK_FCT_DO( fd_msg_free(msg), /* continue */); 168 } 169 166 170 /* Destroy the connection object if present */ 167 171 if (c->conn) … … 170 174 /* Cleanup the received buffer if any */ 171 175 free(buf); 172 173 /* Cleanup the parsed message if any */174 if (msg) {175 CHECK_FCT_DO( fd_msg_free(msg), /* continue */);176 }177 176 178 177 /* Detach the thread, cleanup the client structure */
Note: See TracChangeset
for help on using the changeset viewer.