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: 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
33 * Author: E. Scott Daniels
35 ***************************************************************************
37 #include "sisetup.h" // get definitions etc
38 #include "sitransport.h"
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
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
49 FD_ZERO( &gptr->readfds ); // reset the read and write sets
50 FD_ZERO( &gptr->writefds );
51 FD_ZERO( &gptr->execpfds );
53 for( tpptr = gptr->tplist; tpptr != NULL; tpptr = nextb ) {
55 if( tpptr->flags & TPF_DELETE ) {
56 SIterm( gptr, tpptr );
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
63 FD_SET( tpptr->fd, &gptr->execpfds ); // set all fds for execpts
65 if( !(tpptr->flags & TPF_DRAIN) ) { // if not draining
66 FD_SET( tpptr->fd, &gptr->readfds ); // set test for data flag
69 if( tpptr->squeue != NULL ) { // stuff pending to send ?
70 FD_SET( tpptr->fd, &gptr->writefds ); // set flag to see if writable
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 ) );
81 gptr->flags &= ~GIF_SESS_CHANGE;
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 ) );