netatalk  4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
comm.c File Reference
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <time.h>
#include <unistd.h>
#include <atalk/cnid_bdb_private.h>
#include <atalk/compat.h>
#include <atalk/logger.h>
#include <atalk/util.h>
#include "db_param.h"
#include "usockfd.h"
#include "comm.h"

Data Structures

struct  connection
 

Macros

#define USE_WRITEV
 

Functions

static void invalidate_fd (int fd)
 
static int check_fd (time_t timeout, const sigset_t *sigmask, time_t *now)
 Check for client requests.
 
int comm_init (struct db_param *dbp, int ctrlfd, int clntfd)
 
int comm_nbe (void)
 
int comm_rcv (struct cnid_dbd_rqst *rqst, time_t timeout, const sigset_t *sigmask, time_t *now)
 
int comm_snd (struct cnid_dbd_rply *rply)
 

Variables

static int control_fd
 
static int cur_fd
 
static struct connectionfd_table
 
static int fd_table_size
 
static int fds_in_use = 0
 

Macro Definition Documentation

◆ USE_WRITEV

#define USE_WRITEV

Function Documentation

◆ check_fd()

static int check_fd ( time_t  timeout,
const sigset_t *  sigmask,
time_t *  now 
)
static

Check for client requests.

We keep up to fd_table_size open descriptors in fd_table. If the table is full and we get a new descriptor via control_fd, we close a random decriptor in the table to make space. The affected client will automatically reconnect. For an EOF (descriptor is closed by the client, so a read here returns 0) comm_rcv will take care of things and clean up fd_table. The same happens for any read/write errors.

◆ comm_init()

int comm_init ( struct db_param dbp,
int  ctrlfd,
int  clntfd 
)

◆ comm_nbe()

int comm_nbe ( void  )

◆ comm_rcv()

int comm_rcv ( struct cnid_dbd_rqst rqst,
time_t  timeout,
const sigset_t *  sigmask,
time_t *  now 
)

◆ comm_snd()

int comm_snd ( struct cnid_dbd_rply rply)

◆ invalidate_fd()

static void invalidate_fd ( int  fd)
static

Variable Documentation

◆ control_fd

int control_fd
static

◆ cur_fd

int cur_fd
static

◆ fd_table

struct connection* fd_table
static

◆ fd_table_size

int fd_table_size
static

◆ fds_in_use

int fds_in_use = 0
static