fda092149a1b69c7e282a81420371fd2cb1a543f
[ric-plt/lib/rmr.git] / src / rmr / si / src / si95 / sibldpoll.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 *  Mnemonic: SIbldpoll
24 *  Abstract: This routine will fill in the read and write fdsets in the
25 *            general info struct based on the current transport provider
26 *            list. Those tb blocks that have something queued to send will
27 *            be added to the write fdset. The fdcount variable will be set to
28 *            the highest sid + 1 and it can be passed to the select system
29 *            call when it is made.
30 *  Parms:    gptr  - Pointer to the general info structure
31 *  Returns:  Nothing
32 *  Date:     26 March 1995
33 *  Author:   E. Scott Daniels
34 *
35 ***************************************************************************
36 */
37 #include "sisetup.h"      //  get definitions etc 
38 #include "sitransport.h"
39
40 extern void SIbldpoll( struct ginfo_blk* gptr  ) {
41         struct tp_blk *tpptr;                                   //  pointer into tp list 
42         struct tp_blk *nextb;                                   //  pointer into tp list 
43
44
45 // FIX ME?  we don't seem to see this flag set
46         //if( gptr->flags & GIF_SESS_CHANGE ) { // session changed, must rebuild the poll lists
47                 gptr->fdcount = -1;                                     //  reset largest sid found 
48
49                 FD_ZERO( &gptr->readfds );                      //  reset the read and write sets 
50                 FD_ZERO( &gptr->writefds );
51                 FD_ZERO( &gptr->execpfds );
52         
53                 for( tpptr = gptr->tplist; tpptr != NULL; tpptr = nextb ) {
54                         nextb = tpptr->next;
55                         if( tpptr->flags & TPF_DELETE ) {
56                                 SIterm( gptr, tpptr );
57                         } else {
58                                 if( tpptr->fd >= 0 ) {                       //  if valid file descriptor 
59                                         if( tpptr->fd >= gptr->fdcount ) {      
60                                                 gptr->fdcount = tpptr->fd + 1;     //  save largest fd (+1) for select 
61                                         }
62         
63                                         FD_SET( tpptr->fd, &gptr->execpfds );     //  set all fds for execpts 
64         
65                                         if( !(tpptr->flags & TPF_DRAIN) ) {                  //  if not draining 
66                                                 FD_SET( tpptr->fd, &gptr->readfds );       //  set test for data flag 
67                                         }
68         
69                                         if( tpptr->squeue != NULL ) {                  //  stuff pending to send ? 
70                                                 FD_SET( tpptr->fd, &gptr->writefds );   //  set flag to see if writable 
71                                         }
72                                 }
73                         }
74
75 /*
76                         memcpy( &gptr->readfds_qs, &gptr->readfds, sizeof( fd_set ) );          // stash for use until change
77                         memcpy( &gptr->writefds_qs, &gptr->writefds, sizeof( fd_set ) );
78                         memcpy( &gptr->execpfds_qs, &gptr->execpfds, sizeof( fd_set ) );
79 */
80
81                         gptr->flags &= ~GIF_SESS_CHANGE;
82                 }
83 /*
84         } else {                                        // sessions are the same we can just dup the quick sets we saved
85                 memcpy( &gptr->readfds, &gptr->readfds_qs, sizeof( fd_set ) );
86                 memcpy( &gptr->writefds, &gptr->writefds_qs, sizeof( fd_set ) );
87                 memcpy( &gptr->execpfds, &gptr->execpfds_qs, sizeof( fd_set ) );
88         }
89 */
90
91 }                                 //  SIbldpoll