* SYNC server state structure.
*/
typedef struct SYNC_server_state {
- int fd; /**< listening socket descriptor */
+ osi_socket fd; /**< listening socket descriptor */
SYNC_endpoint_t endpoint; /**< server endpoint address */
afs_uint32 proto_version; /**< our protocol version */
int bind_retry_limit; /**< upper limit on times to retry socket bind() */
* SYNC client state structure.
*/
typedef struct SYNC_client_state {
- int fd; /**< client socket descriptor */
+ osi_socket fd; /**< client socket descriptor */
SYNC_endpoint_t endpoint; /**< address of sync server */
afs_uint32 proto_version; /**< our protocol version */
int retry_limit; /**< max number of times for SYNC_ask to retry */
} SYNC_response;
/* general prototypes */
-extern int SYNC_getSock(SYNC_endpoint_t * endpoint);
+extern osi_socket SYNC_getSock(SYNC_endpoint_t * endpoint);
extern void SYNC_getAddr(SYNC_endpoint_t * endpoint, SYNC_sockaddr_t * addr);
/* client-side prototypes */
extern int SYNC_reconnect(SYNC_client_state *); /* do a reconnect after a protocol error, or from a forked child */
/* server-side prototypes */
-extern int SYNC_getCom(SYNC_server_state_t *, int fd, SYNC_command * com);
-extern int SYNC_putRes(SYNC_server_state_t *, int fd, SYNC_response * res);
+extern int SYNC_getCom(SYNC_server_state_t *, osi_socket fd, SYNC_command * com);
+extern int SYNC_putRes(SYNC_server_state_t *, osi_socket fd, SYNC_response * res);
extern int SYNC_verifyProtocolString(char * buf, size_t len);
extern void SYNC_cleanupSock(SYNC_server_state_t * state);
extern int SYNC_bindSock(SYNC_server_state_t * state);
/* Forward declarations */
static void * FSYNC_sync(void *);
static void FSYNC_newconnection(osi_socket afd);
-static void FSYNC_com(int fd);
-static void FSYNC_Drop(int fd);
+static void FSYNC_com(osi_socket fd);
+static void FSYNC_Drop(osi_socket fd);
static void AcceptOn(void);
static void AcceptOff(void);
static void InitHandler(void);
-static int AddHandler(int fd, void (*aproc)(int));
-static int FindHandler(int afd);
-static int FindHandler_r(int afd);
-static int RemoveHandler(int afd);
+static int AddHandler(osi_socket fd, void (*aproc)(int));
+static int FindHandler(osi_socket afd);
+static int FindHandler_r(osi_socket afd);
+static int RemoveHandler(osi_socket afd);
#if defined(HAVE_POLL) && defined (AFS_PTHREAD_ENV)
static void CallHandler(struct pollfd *fds, int nfds, int mask);
static void GetHandler(struct pollfd *fds, int maxfds, int events, int *nfds);
#endif
extern int LogLevel;
-static afs_int32 FSYNC_com_VolOp(int fd, SYNC_command * com, SYNC_response * res);
+static afs_int32 FSYNC_com_VolOp(osi_socket fd, SYNC_command * com, SYNC_response * res);
#ifdef AFS_DEMAND_ATTACH_FS
static afs_int32 FSYNC_com_VolError(FSSYNC_VolOp_command * com, SYNC_response * res);
static afs_int32 FSYNC_com_VolOpQuery(FSSYNC_VolOp_command * com, SYNC_response * res);
#endif /* AFS_DEMAND_ATTACH_FS */
-static afs_int32 FSYNC_com_VnQry(int fd, SYNC_command * com, SYNC_response * res);
+static afs_int32 FSYNC_com_VnQry(osi_socket fd, SYNC_command * com, SYNC_response * res);
-static afs_int32 FSYNC_com_StatsOp(int fd, SYNC_command * com, SYNC_response * res);
+static afs_int32 FSYNC_com_StatsOp(osi_socket fd, SYNC_command * com, SYNC_response * res);
static afs_int32 FSYNC_com_StatsOpGeneral(FSSYNC_StatsOp_command * scom, SYNC_response * res);
/* this function processes commands from an fssync file descriptor (fd) */
afs_int32 FS_cnt = 0;
static void
-FSYNC_com(int fd)
+FSYNC_com(osi_socket fd)
{
SYNC_command com;
SYNC_response res;
}
static afs_int32
-FSYNC_com_VolOp(int fd, SYNC_command * com, SYNC_response * res)
+FSYNC_com_VolOp(osi_socket fd, SYNC_command * com, SYNC_response * res)
{
int i;
afs_int32 code = SYNC_OK;
#endif /* AFS_DEMAND_ATTACH_FS */
static afs_int32
-FSYNC_com_VnQry(int fd, SYNC_command * com, SYNC_response * res)
+FSYNC_com_VnQry(osi_socket fd, SYNC_command * com, SYNC_response * res)
{
afs_int32 code = SYNC_OK;
FSSYNC_VnQry_hdr * qry = com->payload.buf;
}
static afs_int32
-FSYNC_com_StatsOp(int fd, SYNC_command * com, SYNC_response * res)
+FSYNC_com_StatsOp(osi_socket fd, SYNC_command * com, SYNC_response * res)
{
afs_int32 code = SYNC_OK;
FSSYNC_StatsOp_command scom;
static void
-FSYNC_Drop(int fd)
+FSYNC_Drop(osi_socket fd)
{
struct offlineInfo *p;
int i;
/* The multiple FD handling code. */
-static int HandlerFD[MAXHANDLERS];
+static osi_socket HandlerFD[MAXHANDLERS];
static void (*HandlerProc[MAXHANDLERS]) (int);
static void
#endif
static int
-AddHandler(int afd, void (*aproc) (int))
+AddHandler(osi_socket afd, void (*aproc) (int))
{
register int i;
ObtainWriteLock(&FSYNC_handler_lock);
}
static int
-FindHandler(register int afd)
+FindHandler(register osi_socket afd)
{
register int i;
ObtainReadLock(&FSYNC_handler_lock);
}
static int
-FindHandler_r(register int afd)
+FindHandler_r(register osi_socket afd)
{
register int i;
for (i = 0; i < MAXHANDLERS; i++)
}
static int
-RemoveHandler(register int afd)
+RemoveHandler(register osi_socket afd)
{
ObtainWriteLock(&FSYNC_handler_lock);
HandlerFD[FindHandler_r(afd)] = -1;
GetHandler(fd_set * fdsetp, int *maxfdp)
{
register int i;
- register int maxfd = -1;
+ register osi_socket maxfd = -1;
FD_ZERO(fdsetp);
ObtainReadLock(&FSYNC_handler_lock); /* just in case */
for (i = 0; i < MAXHANDLERS; i++)
if (HandlerFD[i] != -1) {
FD_SET(HandlerFD[i], fdsetp);
- if (maxfd < HandlerFD[i])
+ if (maxfd < HandlerFD[i] || maxfd == (osi_socket)-1)
maxfd = HandlerFD[i];
}
*maxfdp = maxfd;
/* Forward declarations */
static void * SALVSYNC_syncThread(void *);
-static void SALVSYNC_newconnection(int fd);
-static void SALVSYNC_com(int fd);
-static void SALVSYNC_Drop(int fd);
+static void SALVSYNC_newconnection(osi_socket fd);
+static void SALVSYNC_com(osi_socket fd);
+static void SALVSYNC_Drop(osi_socket fd);
static void AcceptOn(void);
static void AcceptOff(void);
static void InitHandler(void);
static void CallHandler(fd_set * fdsetp);
-static int AddHandler(int afd, void (*aproc) (int));
-static int FindHandler(register int afd);
-static int FindHandler_r(register int afd);
-static int RemoveHandler(register int afd);
+static int AddHandler(osi_socket afd, void (*aproc) (int));
+static int FindHandler(register osi_socket afd);
+static int FindHandler_r(register osi_socket afd);
+static int RemoveHandler(register osi_socket afd);
static void GetHandler(fd_set * fdsetp, int *maxfdp);
static int AllocNode(struct SalvageQueueNode ** node);
/* this function processes commands from an salvsync file descriptor (fd) */
static afs_int32 SALV_cnt = 0;
static void
-SALVSYNC_com(int fd)
+SALVSYNC_com(osi_socket fd)
{
SYNC_command com;
SYNC_response res;
}
static void
-SALVSYNC_Drop(int fd)
+SALVSYNC_Drop(osi_socket fd)
{
RemoveHandler(fd);
#ifdef AFS_NT40_ENV
}
static int
-AddHandler(int afd, void (*aproc) (int))
+AddHandler(osi_socket afd, void (*aproc) (int))
{
register int i;
ObtainWriteLock(&SALVSYNC_handler_lock);
}
static int
-FindHandler(register int afd)
+FindHandler(register osi_socket afd)
{
register int i;
ObtainReadLock(&SALVSYNC_handler_lock);
}
static int
-FindHandler_r(register int afd)
+FindHandler_r(register osi_socket afd)
{
register int i;
for (i = 0; i < MAXHANDLERS; i++)
}
static int
-RemoveHandler(register int afd)
+RemoveHandler(register osi_socket afd)
{
ObtainWriteLock(&SALVSYNC_handler_lock);
HandlerFD[FindHandler_r(afd)] = -1;