Add safe connect, fix possible seg fault in RTC
[ric-plt/lib/rmr.git] / src / rmr / si / src / si95 / sishutdown.c
1 // vim: noet sw=4 ts=4:
2 /*
3 ==================================================================================
4     Copyright (c) 2020 Nokia
5     Copyright (c) 2020 AT&T Intellectual Property.
6
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
10
11        http://www.apache.org/licenses/LICENSE-2.0
12
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 ==================================================================================
19 */
20
21 /*
22 ******************************************************************************
23 *
24 *  Mnemonic: SIshutdown
25 *  Abstract: Shutdown and abort functions.
26 *
27 *  Date:     23 March 1995
28 *  Author:   E. Scott Daniels
29 *
30 *****************************************************************************
31 */
32 #include "sisetup.h"                   //  get includes and defines
33
34 /*
35 */
36 static void sishutdown( struct ginfo_blk *gptr, int flags ) {
37         struct tp_blk*  tpb;
38
39         if( gptr != NULL && gptr->magicnum == MAGICNUM )
40         {
41                 gptr->flags |=  GIF_SHUTDOWN;    //  signal shutdown
42                 for( tpb = gptr->tplist; tpb != NULL; tpb = tpb->next )
43                 {
44                         tpb->flags |= (TPF_UNBIND | flags);    //  force unbind on session  and set caller flags
45                         SIterm( gptr, tpb );                                    // term marks ok to delete but does NOT remove it
46                 }
47         }
48 }
49
50 /*
51         Run the list of known transport sessions and close them gracefully. This
52         will result in time-waits which might prevent the application from
53         restarting immediately as the listen port(s) might not be usable.
54 */
55 extern void SIshutdown( struct ginfo_blk *gptr ) {
56         sishutdown( gptr, 0 );
57 }
58
59 /*
60         Run the list of known transport sessions and close them by aborting
61         (resetting the connection). This can result in buffered, but untransmitted,
62         data from being lost; the risk should be known by the caller.
63 */
64 extern void SIabort( struct ginfo_blk *gptr ) {
65         sishutdown( gptr, TPF_ABORT );
66 }