Navigation


Changeset 191:de80f6a76c4f in freeDiameter


Ignore:
Timestamp:
Feb 5, 2010, 6:12:47 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Another attempt to workround the crash issue...

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • freeDiameter/tcp.c

    r184 r191  
    118118int fd_tcp_client( int *sock, sSA * sa, socklen_t salen )
    119119{
     120        int ret = 0;
     121        int s;
     122       
    120123        TRACE_ENTRY("%p %p %d", sock, sa, salen);
    121         CHECK_PARAMS( sock && sa && salen );
     124        CHECK_PARAMS( sock && (*sock <= 0) && sa && salen );
    122125       
    123126        /* Create the socket */
    124         CHECK_SYS(  *sock = socket(sa->sa_family, SOCK_STREAM, IPPROTO_TCP)  );
     127        CHECK_SYS(  s = socket(sa->sa_family, SOCK_STREAM, IPPROTO_TCP)  );
    125128       
    126129        /* Cleanup if we are cancelled */
    127         pthread_cleanup_push(fd_cleanup_socket, sock);
     130        pthread_cleanup_push(fd_cleanup_socket, &s);
    128131       
    129132        /* Set the socket options */
    130         CHECK_FCT(  fd_tcp_setsockopt(sa->sa_family, *sock)  );
     133        CHECK_FCT(  fd_tcp_setsockopt(sa->sa_family, s)  );
    131134       
    132135        TRACE_DEBUG_sSA(FULL, "Attempting TCP connection with peer: ", sa, NI_NUMERICHOST | NI_NUMERICSERV, "..." );
    133136       
    134137        /* Try connecting to the remote address */
    135         CHECK_SYS_DO( connect(*sock, sa, salen), { int ret = errno; close(*sock); *sock = -1; return ret; } );
     138        CHECK_SYS_DO( connect(s, sa, salen), { ret = errno; close(s); s = -1; } );
    136139       
    137140        /* Done! */
    138141        pthread_cleanup_pop(0);
    139         return 0;
     142        *sock = s;
     143        return ret;
    140144}
    141145
  • include/freeDiameter/libfreeDiameter.h

    r184 r191  
    522522static __inline__ void fd_cleanup_socket(void * sockptr)
    523523{
    524         if (sockptr) {
     524        if (sockptr && (*(int *)sockptr > 0)) {
    525525                CHECK_SYS_DO( close(*(int *)sockptr), /* ignore */ );
    526526                *(int *)sockptr = -1;
Note: See TracChangeset for help on using the changeset viewer.