Navigation


Changeset 691:78b665400097 in freeDiameter for libfdcore/p_cnx.c


Ignore:
Timestamp:
Jan 20, 2011, 7:44:27 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Cleanup all pthread_cleanup_push / pop pairs so that pop is always called after push, or ASSERT(0) is some grave errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdcore/p_cnx.c

    r662 r691  
    211211        struct next_conn * nc = NULL;
    212212        int rebuilt = 0;
     213        int fatal_error=0;
    213214       
    214215        TRACE_ENTRY("%p", arg);
     
    226227                if (FD_IS_LIST_EMPTY(&peer->p_connparams)) {
    227228                        if (! rebuilt) {
    228                                 CHECK_FCT_DO( prepare_connection_list(peer), goto fatal_error );
     229                                CHECK_FCT_DO( fatal_error = prepare_connection_list(peer), goto out );
    229230                                rebuilt ++;
    230231                        }
     
    232233                                /* We encountered an error or we have looped over all the addresses of the peer. */
    233234                                TRACE_DEBUG(INFO, "Unable to connect to the peer %s, aborting attempts for now.", peer->p_hdr.info.pi_diamid);
    234                                 CHECK_FCT_DO( fd_event_send(peer->p_events, FDEVP_CNX_FAILED, 0, NULL), goto fatal_error );
     235                                CHECK_FCT_DO( fatal_error = fd_event_send(peer->p_events, FDEVP_CNX_FAILED, 0, NULL), goto out );
    235236                                return NULL;
    236237                        }
     
    277278                                empty_connection_list(peer);
    278279                                fd_ep_filter(&peer->p_hdr.info.pi_endpoints, EP_FL_CONF);
    279                                 return NULL;
     280                                goto out_pop;
    280281                        } );
    281282        } else {
    282283                /* Prepare to receive the next message */
    283                 CHECK_FCT_DO( fd_cnx_start_clear(cnx, 0), goto fatal_error );
     284                CHECK_FCT_DO( fatal_error = fd_cnx_start_clear(cnx, 0), goto out_pop );
    284285        }
    285286       
    286287        /* Upon success, generate FDEVP_CNX_ESTABLISHED */
    287         CHECK_FCT_DO( fd_event_send(peer->p_events, FDEVP_CNX_ESTABLISHED, 0, cnx), goto fatal_error );
    288        
     288        CHECK_FCT_DO( fatal_error = fd_event_send(peer->p_events, FDEVP_CNX_ESTABLISHED, 0, cnx),  );
     289out_pop:
     290        ;       
    289291        pthread_cleanup_pop(0);
    290292       
    291         return NULL;
    292        
    293 fatal_error:
    294         /* Cleanup the connection */
    295         if (cnx)
    296                 fd_cnx_destroy(cnx);
    297 
    298         /* Generate a termination event */
    299         CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, 0, NULL), );
     293out:
     294       
     295        if (fatal_error) {
     296       
     297                /* Cleanup the connection */
     298                if (cnx)
     299                        fd_cnx_destroy(cnx);
     300
     301                /* Generate a termination event */
     302                CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_TERMINATE, 0, NULL), );
     303        }
    300304       
    301305        return NULL;
Note: See TracChangeset for help on using the changeset viewer.