Add request timeouts
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
@@ -284,6 +285,16 @@ typedef struct {
|
||||
// Returns 0 on success, -1 on error
|
||||
int chttp_parse_set_cookie(CHTTP_String str, CHTTP_SetCookie *out);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// src/time.h
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef uint64_t Time;
|
||||
|
||||
#define INVALID_TIME ((Time) UINT64_MAX-1)
|
||||
|
||||
Time get_current_time(void);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// src/secure_context.h
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -398,6 +409,8 @@ typedef uint16_t Port;
|
||||
|
||||
typedef enum {
|
||||
SOCKET_EVENT_READY,
|
||||
SOCKET_EVENT_CREATION_TIMEOUT,
|
||||
SOCKET_EVENT_RECV_TIMEOUT,
|
||||
SOCKET_EVENT_DISCONNECT,
|
||||
} SocketEventType;
|
||||
|
||||
@@ -495,6 +508,12 @@ typedef struct {
|
||||
// User-provided context pointer
|
||||
void *user;
|
||||
|
||||
Time creation_time;
|
||||
Time last_recv_time;
|
||||
|
||||
Time recv_timeout;
|
||||
Time creation_timeout;
|
||||
|
||||
// A single connect operation may involve
|
||||
// trying to establish a connection towards
|
||||
// one of a set of addresses.
|
||||
@@ -519,6 +538,10 @@ typedef struct {
|
||||
// header.
|
||||
typedef struct {
|
||||
|
||||
// TODO: comment
|
||||
Time recv_timeout;
|
||||
Time creation_timeout;
|
||||
|
||||
// TCP listener sockets. The first is intended
|
||||
// for plaintext, while the second is for TLS.
|
||||
// The socket manager will accept and add new
|
||||
@@ -567,6 +590,9 @@ int socket_manager_init(SocketManager *sm, Socket *socks,
|
||||
// Deinitialize a socket manager
|
||||
void socket_manager_free(SocketManager *sm);
|
||||
|
||||
void socket_manager_set_creation_timeout(SocketManager *sm, int timeout);
|
||||
void socket_manager_set_recv_timeout(SocketManager *sm, int timeout);
|
||||
|
||||
// Configure the socket manager to listen on
|
||||
// the specified interface for TCP connections.
|
||||
// Incoming connections will be automatically
|
||||
@@ -608,6 +634,7 @@ typedef struct {
|
||||
void **ptrs;
|
||||
struct pollfd *polled;
|
||||
int num_polled;
|
||||
int timeout;
|
||||
} EventRegister;
|
||||
|
||||
// Resets the event register with the list of descriptors
|
||||
|
||||
Reference in New Issue
Block a user