X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Frmr%2Fsi%2Fsrc%2Fsi95%2Fsinewses.c;h=8665892ddd6d9ac97b183e62e80fede384a90884;hb=fa454008020483ac35e1d20300cddfe877d8dd6d;hp=0b00ba40287922349870530fde7fdd5c00ea67b6;hpb=ec88d3c0563eeb6ae5f73427edb0b3c4d7acf299;p=ric-plt%2Flib%2Frmr.git diff --git a/src/rmr/si/src/si95/sinewses.c b/src/rmr/si/src/si95/sinewses.c index 0b00ba4..8665892 100644 --- a/src/rmr/si/src/si95/sinewses.c +++ b/src/rmr/si/src/si95/sinewses.c @@ -52,6 +52,7 @@ extern int SInewsession( struct ginfo_blk *gptr, struct tp_blk *tpptr ) { addr = (struct sockaddr *) malloc( sizeof( struct sockaddr ) ); addrlen = sizeof( struct sockaddr ); + memset( addr, 0, sizeof( struct sockaddr ) ); status = accept( tpptr->fd, addr, &addrlen ); // accept and assign new fd (status) if( status < 0 ) { @@ -61,7 +62,7 @@ extern int SInewsession( struct ginfo_blk *gptr, struct tp_blk *tpptr ) { newtp = SInew( TP_BLK ); // get a new tp block for the session if( newtp == NULL ) { - close( status ); // must disconnect the other side + CLOSE( status ); // must disconnect the other side free( addr ); return SI_ERROR; } @@ -71,34 +72,29 @@ extern int SInewsession( struct ginfo_blk *gptr, struct tp_blk *tpptr ) { newtp->next->prev = newtp; // back chain to us } gptr->tplist = newtp; - newtp->paddr = (struct sockaddr *) addr; // partner address + newtp->paddr = (struct sockaddr *) addr; // partner address newtp->fd = status; // save the fd from accept - //fprintf( stderr, ">>>>> newsession: accepted session on fd %d\n", status ); - if( gptr->tcp_flags & SI_TF_NODELAY ) { + if( gptr->tcp_flags & SI_TF_NODELAY ) { // set on/off for no delay configuration optval = 1; } else { optval = 0; } - //fprintf( stderr, ">>>>> newsession: setting no delay = %d\n", optval ); - SETSOCKOPT( tpptr->fd, SOL_TCP, TCP_NODELAY, (void *)&optval, sizeof( optval) ) ; + SETSOCKOPT( tpptr->fd, SOL_TCP, TCP_NODELAY, (void *)&optval, sizeof( optval) ); - - if( gptr->tcp_flags & SI_TF_FASTACK ) { + if( gptr->tcp_flags & SI_TF_FASTACK ) { // set on/off for fast ack config optval = 1; } else { optval = 0; } - //fprintf( stderr, ">>>>> conn_prep: setting quick ack = %d\n", optval ); SETSOCKOPT( tpptr->fd, SOL_TCP, TCP_QUICKACK, (void *)&optval, sizeof( optval) ) ; - SIaddress( addr, (void **) &buf, AC_TODOT ); // get addr of remote side - if( (cbptr = gptr->cbtab[SI_CB_SECURITY].cbrtn) != NULL ) { // invoke the security callback function if there + SIaddress( addr, (void **) &buf, AC_TODOT ); // get addr of remote side; buf must be freed + if( (cbptr = gptr->cbtab[SI_CB_SECURITY].cbrtn) != NULL ) { // invoke the security callback function if there status = (*cbptr)( gptr->cbtab[SI_CB_SECURITY].cbdata, buf ); if( status == SI_RET_ERROR ) { // session to be rejected - SIterm( gptr, newtp ); // terminate new tp block - SItrash( TP_BLK, newtp ); - free( addr ); + SIterm( gptr, newtp ); // terminate new tp block (do NOT call trash) + // free( addr ); // not required, will be eventually freed by SItrash free( buf ); return SI_ERROR; } else { @@ -108,15 +104,14 @@ extern int SInewsession( struct ginfo_blk *gptr, struct tp_blk *tpptr ) { newtp->flags |= TPF_SESSION; // indicate a session here - //fprintf( stderr, ">>>> pending connection callback for: %s\n", buf ); if( (cbptr = gptr->cbtab[SI_CB_CONN].cbrtn) != NULL ) { // drive connection callback status=(*cbptr)( gptr->cbtab[SI_CB_CONN].cbdata, newtp->fd, buf ); SIcbstat( gptr, status, SI_CB_CONN ); // handle status } - gptr->flags |= GIF_SESS_CHANGE; // sessions changed must rebuild the poll list SImap_fd( gptr, newtp->fd, newtp ); // add fd to the map + free( buf ); return SI_OK; }