Changeset 1103:d8591b1c56cd in freeDiameter for libfdproto
- Timestamp:
- May 10, 2013, 7:48:57 PM (11 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libfdproto
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdproto/fifo.c
r1093 r1103 412 412 CHECK_MALLOC_DO( new = malloc (sizeof (struct fifo_item)) , { 413 413 pthread_mutex_unlock( &queue->mtx ); 414 return ENOMEM; 414 415 } ); 415 416 … … 470 471 ASSERT( ! FD_IS_LIST_EMPTY(&queue->list) ); 471 472 472 fi = (struct fifo_item *)queue->list.next; 473 fi = (struct fifo_item *)(queue->list.next); 474 ret = fi->item.o; 473 475 fd_list_unlink(&fi->item); 474 476 queue->count--; 475 477 queue->total_items++; 476 ret = fi->item.o;477 478 478 479 /* Update the timings */ … … 598 599 return EPIPE; 599 600 } 600 601 601 602 if (queue->count > 0) { 602 603 /* There are items in the queue, so pick the first one */ -
libfdproto/messages.c
r1101 r1103 202 202 init_chain( &msg->msg_chain, MSG_MSG); 203 203 msg->msg_eyec = MSG_MSG_EYEC; 204 205 fd_list_init(&msg->msg_pmdl.sentinel, NULL); 206 CHECK_POSIX_DO( pthread_mutex_init(&msg->msg_pmdl.lock, NULL), ); 204 207 } 205 208 … … 1952 1955 CHECK_PARAMS( buffer && *buffer && msg && (buflen >= GETMSGHDRSZ()) ); 1953 1956 buf = *buffer; 1954 *buffer = NULL;1955 1957 1956 1958 if ( buf[0] != DIAMETER_VERSION) { 1957 1959 TRACE_DEBUG(INFO, "Invalid version in message: %d (supported: %d)", buf[0], DIAMETER_VERSION); 1958 free(buf);1959 1960 return EBADMSG; 1960 1961 } … … 1963 1964 if ( buflen < msglen ) { 1964 1965 TRACE_DEBUG(INFO, "Truncated message (%zd / %d)", buflen, msglen ); 1965 free(buf);1966 1966 return EBADMSG; 1967 1967 } 1968 1968 1969 1969 /* Create a new object */ 1970 CHECK_MALLOC _DO( new = malloc (sizeof(struct msg)), { free(buf); return ENOMEM; });1970 CHECK_MALLOC( new = malloc (sizeof(struct msg)) ); 1971 1971 1972 1972 /* Initialize the fields */ … … 1984 1984 new->msg_public.msg_eteid = ntohl(*(uint32_t *)(buf+16)); 1985 1985 1986 new->msg_rawbuffer = buf;1987 1988 1986 /* Parse the AVP list */ 1989 1987 CHECK_FCT_DO( ret = parsebuf_list(buf + GETMSGHDRSZ(), buflen - GETMSGHDRSZ(), &new->msg_chain.children), { destroy_tree(_C(new)); return ret; } ); 1990 1988 1989 /* Parsing successful */ 1990 new->msg_rawbuffer = buf; 1991 *buffer = NULL; 1991 1992 *msg = new; 1992 1993 return 0; -
libfdproto/utils.c
r1093 r1103 66 66 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s", gai_strerror(rc)), return NULL); 67 67 } else { 68 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s ", &addrbuf[0]), return NULL);68 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "%s(s)", &addrbuf[0], &servbuf[0]), return NULL); 69 69 } 70 70 } else { … … 73 73 return *buf; 74 74 } 75 76 void fd_sa_sdump_numeric(char * buf /* must be at least sSA_DUMP_STRLEN */, sSA * sa) 77 { 78 char addrbuf[INET6_ADDRSTRLEN]; 79 char servbuf[32]; 80 81 if (sa) { 82 int rc = getnameinfo(sa, sSAlen( sa ), addrbuf, sizeof(addrbuf), servbuf, sizeof(servbuf), NI_NUMERICHOST | NI_NUMERICSERV); 83 if (rc) { 84 snprintf(buf, sSA_DUMP_STRLEN, "%s", gai_strerror(rc)); 85 } else { 86 snprintf(buf, sSA_DUMP_STRLEN, "%s(%s)", addrbuf, servbuf); 87 } 88 } else { 89 snprintf(buf, sSA_DUMP_STRLEN, "(NULL / ANY)"); 90 } 91 92 }
Note: See TracChangeset
for help on using the changeset viewer.