NeoMutt  2025-12-11-980-ge38c27
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches

Check whether a socket read would block. More...

+ Collaboration diagram for poll():

Functions

static int tls_socket_poll (struct Connection *conn, time_t wait_secs)
 Check if any data is waiting on a socket - Implements Connection::poll() -.
 
static int ssl_socket_poll (struct Connection *conn, time_t wait_secs)
 Check if any data is waiting on a socket - Implements Connection::poll() -.
 
int raw_socket_poll (struct Connection *conn, time_t wait_secs)
 Check if any data is waiting on a socket - Implements Connection::poll() -.
 
static int mutt_sasl_conn_poll (struct Connection *conn, time_t wait_secs)
 Check if any data is waiting on a socket - Implements Connection::poll() -.
 
static int tunnel_socket_poll (struct Connection *conn, time_t wait_secs)
 Check if any data is waiting on a socket - Implements Connection::poll() -.
 
static int zstrm_poll (struct Connection *conn, time_t wait_secs)
 Check if any data is waiting on a socket - Implements Connection::poll() -.
 

Variables

int(* SaslSockData::poll )(struct Connection *conn, time_t wait_secs)
 Check if any data is waiting on a socket - Implements Connection::poll() -.
 

Detailed Description

Check whether a socket read would block.

Parameters
connConnection to a server
wait_secsHow long to wait for a response
Return values
>0There is data to read
0Read would block
-1Connection doesn't support polling

Function Documentation

◆ tls_socket_poll()

static int tls_socket_poll ( struct Connection * conn,
time_t wait_secs )
static

Check if any data is waiting on a socket - Implements Connection::poll() -.

Definition at line 1006 of file gnutls.c.

1007{
1008 struct TlsSockData *data = conn->sockdata;
1009 if (!data)
1010 return -1;
1011
1012 if (gnutls_record_check_pending(data->session))
1013 return 1;
1014
1015 return raw_socket_poll(conn, wait_secs);
1016}
int raw_socket_poll(struct Connection *conn, time_t wait_secs)
Check if any data is waiting on a socket - Implements Connection::poll() -.
Definition raw.c:354
void * sockdata
Backend-specific socket data.
Definition connection.h:55
This array needs to be large enough to hold all the possible values support by NeoMutt.
Definition gnutls.c:82
gnutls_session_t session
GNUTLS session.
Definition gnutls.c:83
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ssl_socket_poll()

static int ssl_socket_poll ( struct Connection * conn,
time_t wait_secs )
static

Check if any data is waiting on a socket - Implements Connection::poll() -.

Definition at line 1315 of file openssl.c.

1316{
1317 if (!conn)
1318 return -1;
1319
1320 if (SSL_has_pending(sockdata(conn)->ssl))
1321 return 1;
1322
1323 return raw_socket_poll(conn, wait_secs);
1324}
static struct SslSockData * sockdata(struct Connection *conn)
Get a Connection's socket data.
Definition openssl.c:1211
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ raw_socket_poll()

int raw_socket_poll ( struct Connection * conn,
time_t wait_secs )

Check if any data is waiting on a socket - Implements Connection::poll() -.

Definition at line 354 of file raw.c.

355{
356 if (conn->fd < 0)
357 return -1;
358
359 fd_set rfds = { 0 };
360 struct timeval tv = { 0 };
361
362 uint64_t wait_millis = wait_secs * 1000UL;
363
364 while (true)
365 {
366 tv.tv_sec = wait_millis / 1000;
367 tv.tv_usec = (wait_millis % 1000) * 1000;
368
369 FD_ZERO(&rfds);
370 FD_SET(conn->fd, &rfds);
371
372 uint64_t pre_t = mutt_date_now_ms();
373 const int rc = select(conn->fd + 1, &rfds, NULL, NULL, &tv);
374 uint64_t post_t = mutt_date_now_ms();
375
376 if ((rc > 0) || ((rc < 0) && (errno != EINTR)))
377 return rc;
378
379 if (SigInt)
381
382 wait_millis += pre_t;
383 if (wait_millis <= post_t)
384 return 0;
385 wait_millis -= post_t;
386 }
387}
void mutt_query_exit(void)
Ask the user if they want to leave NeoMutt.
Definition curs_lib.c:138
uint64_t mutt_date_now_ms(void)
Return the number of milliseconds since the Unix epoch.
Definition date.c:468
volatile sig_atomic_t SigInt
true after SIGINT is received
Definition signal.c:68
int fd
Socket file descriptor.
Definition connection.h:53
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mutt_sasl_conn_poll()

static int mutt_sasl_conn_poll ( struct Connection * conn,
time_t wait_secs )
static

Check if any data is waiting on a socket - Implements Connection::poll() -.

Definition at line 590 of file sasl.c.

591{
592 struct SaslSockData *sasldata = conn->sockdata;
593 int rc;
594
595 conn->sockdata = sasldata->sockdata;
596 rc = sasldata->poll(conn, wait_secs);
597 conn->sockdata = sasldata;
598
599 return rc;
600}
int(* poll)(struct Connection *conn, time_t wait_secs)
Check if any data is waiting on a socket - Implements Connection::poll() -.
Definition sasl.c:96
SASL authentication API -.
Definition sasl.c:66
void * sockdata
Underlying socket data.
Definition sasl.c:76
+ Here is the caller graph for this function:

◆ tunnel_socket_poll()

static int tunnel_socket_poll ( struct Connection * conn,
time_t wait_secs )
static

Check if any data is waiting on a socket - Implements Connection::poll() -.

Definition at line 197 of file tunnel.c.

198{
199 struct TunnelSockData *tunnel = conn->sockdata;
200 int ofd;
201 int rc;
202
203 ofd = conn->fd;
204 conn->fd = tunnel->fd_read;
205 rc = raw_socket_poll(conn, wait_secs);
206 conn->fd = ofd;
207
208 return rc;
209}
A network tunnel (pair of sockets)
Definition tunnel.c:49
int fd_read
File descriptor to read from.
Definition tunnel.c:51
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ zstrm_poll()

static int zstrm_poll ( struct Connection * conn,
time_t wait_secs )
static

Check if any data is waiting on a socket - Implements Connection::poll() -.

Definition at line 220 of file zstrm.c.

221{
222 struct ZstrmContext *zctx = conn->sockdata;
223
224 mutt_debug(LL_DEBUG5, "%s\n",
225 (zctx->read.z.avail_out == 0) || (zctx->read.pos > 0) ?
226 "last read wrote full buffer" :
227 "falling back on next stream");
228 if ((zctx->read.z.avail_out == 0) || (zctx->read.pos > 0))
229 return 1;
230
231 return zctx->next_conn.poll(&zctx->next_conn, wait_secs);
232}
#define mutt_debug(LEVEL,...)
Definition logging2.h:91
@ LL_DEBUG5
Log at debug level 5.
Definition logging2.h:49
int(* poll)(struct Connection *conn, time_t wait_secs)
Definition connection.h:105
Data compression layer.
Definition zstrm.c:58
struct ZstrmDirection read
Data being read and de-compressed.
Definition zstrm.c:59
struct Connection next_conn
Underlying stream.
Definition zstrm.c:61
unsigned int pos
Current position.
Definition zstrm.c:49
z_stream z
zlib compression handle
Definition zstrm.c:46
+ Here is the caller graph for this function:

Variable Documentation

◆ poll

int(* SaslSockData::poll) (struct Connection *conn, time_t wait_secs)

Check if any data is waiting on a socket - Implements Connection::poll() -.

Definition at line 96 of file sasl.c.