1 // vim: noet sw=4 ts=4:
3 ==================================================================================
4 Copyright (c) 2020 Nokia
5 Copyright (c) 2020 AT&T Intellectual Property.
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ==================================================================================
22 **************************************************************************
24 * Abstract: Manage the transport provider block information relating to
25 * the need to terminate the session. The block is left in the
26 * list; it is unsafe to clean the lsit up outside of the SIwait
27 * thread. When safe, the SIrm_tpb() function can be called to
28 * do the rest of the work that was originally done by SIterm.
30 * Date: 18 January 1995
31 * Author: E. Scott Daniels
33 **************************************************************************
35 #include "sisetup.h" // get the setup stuff
36 #include "sitransport.h"
39 Close the FD and mark the transport block as unusable/closed.
40 Removal of the block from the list is safe only from the siwait
43 extern void SIterm( struct ginfo_blk* gptr, struct tp_blk *tpptr ) {
46 if( tpptr->fd >= 0 ) {
48 if( tpptr->fd < MAX_FDS ) {
49 gptr->tp_map[tpptr->fd] = NULL; // drop reference
53 tpptr->fd = -1; // prevent future sends etc.
54 tpptr->flags |= TPF_DELETE; // signal block deletion needed when safe
59 It is safe to remove the block from the list; if it was in the list
62 extern void SIrm_tpb( struct ginfo_blk *gptr, struct tp_blk *tpptr ) {
65 if( tpptr->prev != NULL || tpptr->next != NULL ) { // in the list
66 if( tpptr->prev != NULL ) { // remove from the list
67 tpptr->prev->next = tpptr->next; // point previous at the next
69 gptr->tplist = tpptr->next; // this was head, make next new head
72 if( tpptr->next != NULL ) {
73 tpptr->next->prev = tpptr->prev; // point next one back behind this one
77 free( tpptr->addr ); // release the address bufers
79 free( tpptr ); // and release the block