Changeset 895:fbf77629cb7b in freeDiameter for libfdproto
- Timestamp:
- Nov 30, 2012, 8:44:10 AM (11 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libfdproto
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdproto/messages.c
r894 r895 128 128 DiamId_t msg_src_id; /* Diameter Id of the peer this message was received from. This string is malloc'd and must be freed */ 129 129 size_t msg_src_id_len; /* cached length of this string */ 130 struct timespec msg_ts; /* Timestamp associated with the message */ 130 struct timespec msg_ts_rcv; /* Timestamp when this message was received from the network */ 131 struct timespec msg_ts_sent; /* Timestamp when this message was sent to the network */ 131 132 132 133 }; … … 678 679 { 679 680 int ret = 0; 681 char buftime[256]; 682 size_t tsoffset = 0; 683 struct tm tm; 680 684 681 685 CHECK_FCT( dump_add_str(outstr, offset, outlen, "%*sMSG: %p\n", INOBJHDRVAL, msg) ); … … 684 688 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "INVALID!\n", INOBJHDRVAL) ); 685 689 return 0; 690 } 691 692 if ((msg->msg_ts_rcv.tv_sec != 0) || (msg->msg_ts_rcv.tv_nsec != 0)) { 693 tsoffset += strftime(buftime + tsoffset, sizeof(buftime) - tsoffset, "%D,%T", localtime_r( &msg->msg_ts_rcv.tv_sec , &tm )); 694 tsoffset += snprintf(buftime + tsoffset, sizeof(buftime) - tsoffset, ".%6.6ld", msg->msg_ts_rcv.tv_nsec / 1000); 695 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "Received: %s\n", INOBJHDRVAL, buftime) ); 696 } 697 if ((msg->msg_ts_sent.tv_sec != 0) || (msg->msg_ts_sent.tv_nsec != 0)) { 698 tsoffset += strftime(buftime + tsoffset, sizeof(buftime) - tsoffset, "%D,%T", localtime_r( &msg->msg_ts_sent.tv_sec , &tm )); 699 tsoffset += snprintf(buftime + tsoffset, sizeof(buftime) - tsoffset, ".%6.6ld", msg->msg_ts_sent.tv_nsec / 1000); 700 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "Sent : %s\n", INOBJHDRVAL, buftime) ); 686 701 } 687 702 … … 734 749 if (!avp->avp_model) { 735 750 736 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(no model )\n", INOBJHDRVAL) );751 CHECK_FCT( dump_add_str(outstr, offset, outlen, INOBJHDR "(no model resolved)\n", INOBJHDRVAL) ); 737 752 738 753 } else { … … 826 841 827 842 /* now really output this in one shot, so it is not interrupted */ 828 fd_log_debug_fstr(fstr, "%s ", outstr);843 fd_log_debug_fstr(fstr, "%s\n", outstr); 829 844 830 845 free(outstr); … … 838 853 fd_log_debug_fstr(fstr, "Error while dumping %p\n", msg) ); 839 854 /* now really output this in one shot, so it is not interrupted */ 840 fd_log_debug_fstr(fstr, "%s ", outstr);855 fd_log_debug_fstr(fstr, "%s\n", outstr); 841 856 842 857 free(outstr); … … 1152 1167 return 0; 1153 1168 } 1169 1170 int fd_msg_ts_set_recv( struct msg * msg, struct timespec * ts ) 1171 { 1172 TRACE_ENTRY("%p %p", msg, ts); 1173 1174 /* Check we received valid parameters */ 1175 CHECK_PARAMS( CHECK_MSG(msg) ); 1176 CHECK_PARAMS( ts ); 1177 1178 memcpy(&msg->msg_ts_rcv, ts, sizeof(struct timespec)); 1179 return 0; 1180 } 1181 1182 int fd_msg_ts_get_recv( struct msg * msg, struct timespec * ts ) 1183 { 1184 TRACE_ENTRY("%p %p", msg, ts); 1185 1186 /* Check we received valid parameters */ 1187 CHECK_PARAMS( CHECK_MSG(msg) ); 1188 CHECK_PARAMS( ts ); 1189 1190 memcpy(ts, &msg->msg_ts_rcv, sizeof(struct timespec)); 1191 return 0; 1192 } 1193 1194 int fd_msg_ts_set_sent( struct msg * msg, struct timespec * ts ) 1195 { 1196 TRACE_ENTRY("%p %p", msg, ts); 1197 1198 /* Check we received valid parameters */ 1199 CHECK_PARAMS( CHECK_MSG(msg) ); 1200 CHECK_PARAMS( ts ); 1201 1202 memcpy(&msg->msg_ts_sent, ts, sizeof(struct timespec)); 1203 return 0; 1204 } 1205 1206 int fd_msg_ts_get_sent( struct msg * msg, struct timespec * ts ) 1207 { 1208 TRACE_ENTRY("%p %p", msg, ts); 1209 1210 /* Check we received valid parameters */ 1211 CHECK_PARAMS( CHECK_MSG(msg) ); 1212 CHECK_PARAMS( ts ); 1213 1214 memcpy(ts, &msg->msg_ts_sent, sizeof(struct timespec)); 1215 return 0; 1216 } 1217 1154 1218 1155 1219 /* Retrieve the session of the message */ -
libfdproto/msg_log.c
r765 r895 166 166 (void)pthread_mutex_lock(&fd_log_lock); 167 167 pthread_cleanup_push(fd_cleanup_mutex_silent, &fd_log_lock); 168 fprintf( fstr, "\n"); 168 169 va_start(ap, prefix_format); 169 170 vfprintf( fstr, prefix_format, ap); … … 173 174 (void)pthread_mutex_unlock(&fd_log_lock); 174 175 175 fd_log_debug_fstr(fstr, "\n Logged: %s\n\n", buftime);176 fd_log_debug_fstr(fstr, "\n Logged: %s\n", buftime); 176 177 177 178 /* And now the message itself */
Note: See TracChangeset
for help on using the changeset viewer.