Add -Wall -Wextra flags to the build script and fix the resulting compiler warnings
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
CFLAGS = -ggdb
|
CFLAGS = -ggdb -Wall -Wextra
|
||||||
LFLAGS =
|
LFLAGS =
|
||||||
|
|
||||||
ifeq ($(shell uname -s),Linux)
|
ifeq ($(shell uname -s),Linux)
|
||||||
|
|||||||
@@ -1765,6 +1765,8 @@ void client_secure_context_free(ClientSecureContext *ctx)
|
|||||||
{
|
{
|
||||||
#ifdef HTTPS_ENABLED
|
#ifdef HTTPS_ENABLED
|
||||||
SSL_CTX_free(ctx->p);
|
SSL_CTX_free(ctx->p);
|
||||||
|
#else
|
||||||
|
(void) ctx;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2227,6 +2229,7 @@ static bool is_secure(Socket *s)
|
|||||||
return s->server_secure_context != NULL
|
return s->server_secure_context != NULL
|
||||||
|| s->client_secure_context != NULL;
|
|| s->client_secure_context != NULL;
|
||||||
#else
|
#else
|
||||||
|
(void) s;
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -2620,7 +2623,6 @@ int socket_manager_wakeup(SocketManager *sm)
|
|||||||
// NOTE: It's assumed send/write operate atomically
|
// NOTE: It's assumed send/write operate atomically
|
||||||
// on The descriptor.
|
// on The descriptor.
|
||||||
char byte = 1;
|
char byte = 1;
|
||||||
int ret = 0;
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (send(sm->signal_sock, &byte, 1, 0) < 0)
|
if (send(sm->signal_sock, &byte, 1, 0) < 0)
|
||||||
return HTTP_ERROR_UNSPECIFIED;
|
return HTTP_ERROR_UNSPECIFIED;
|
||||||
@@ -2733,10 +2735,6 @@ int socket_manager_translate_events(
|
|||||||
if (sm->num_used == sm->max_used)
|
if (sm->num_used == sm->max_used)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Determine whether the event came from
|
|
||||||
// the encrypted listener or not.
|
|
||||||
bool secure = (reg.polled[i].fd == sm->secure_sock);
|
|
||||||
|
|
||||||
Socket *s = sm->sockets;
|
Socket *s = sm->sockets;
|
||||||
while (s->state != SOCKET_STATE_FREE) {
|
while (s->state != SOCKET_STATE_FREE) {
|
||||||
s++;
|
s++;
|
||||||
@@ -2757,6 +2755,10 @@ int socket_manager_translate_events(
|
|||||||
s->events = 0;
|
s->events = 0;
|
||||||
s->user = NULL;
|
s->user = NULL;
|
||||||
#ifdef HTTPS_ENABLED
|
#ifdef HTTPS_ENABLED
|
||||||
|
// Determine whether the event came from
|
||||||
|
// the encrypted listener or not.
|
||||||
|
bool secure = (reg.polled[i].fd == sm->secure_sock);
|
||||||
|
|
||||||
s->ssl = NULL;
|
s->ssl = NULL;
|
||||||
s->server_secure_context = NULL;
|
s->server_secure_context = NULL;
|
||||||
s->client_secure_context = NULL;
|
s->client_secure_context = NULL;
|
||||||
@@ -2996,6 +2998,8 @@ int socket_connect(SocketManager *sm, int num_targets,
|
|||||||
s->client_secure_context = &sm->client_secure_context;
|
s->client_secure_context = &sm->client_secure_context;
|
||||||
s->dont_verify_cert = dont_verify_cert;
|
s->dont_verify_cert = dont_verify_cert;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void) dont_verify_cert;
|
||||||
#endif
|
#endif
|
||||||
sm->num_used++;
|
sm->num_used++;
|
||||||
|
|
||||||
@@ -3069,6 +3073,9 @@ int socket_recv(SocketManager *sm, SocketHandle handle,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
#else
|
||||||
|
// Unreachable
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3117,13 +3124,15 @@ int socket_send(SocketManager *sm, SocketHandle handle,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
#else
|
||||||
|
// Unreachable
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void socket_close(SocketManager *sm, SocketHandle handle)
|
void socket_close(SocketManager *sm, SocketHandle handle)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
Socket *s = handle_to_socket(sm, handle);
|
Socket *s = handle_to_socket(sm, handle);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -3154,7 +3163,6 @@ void socket_set_user(SocketManager *sm, SocketHandle handle, void *user)
|
|||||||
|
|
||||||
bool socket_ready(SocketManager *sm, SocketHandle handle)
|
bool socket_ready(SocketManager *sm, SocketHandle handle)
|
||||||
{
|
{
|
||||||
bool ready = false;
|
|
||||||
Socket *s = handle_to_socket(sm, handle);
|
Socket *s = handle_to_socket(sm, handle);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return false;
|
return false;
|
||||||
@@ -3349,7 +3357,7 @@ int byte_queue_write_setmincap(ByteQueue *queue, uint32_t mincap)
|
|||||||
if (size > queue->limit)
|
if (size > queue->limit)
|
||||||
size = queue->limit;
|
size = queue->limit;
|
||||||
|
|
||||||
uint8_t *data = malloc(size);
|
char *data = malloc(size);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
queue->flags |= BYTE_QUEUE_ERROR;
|
queue->flags |= BYTE_QUEUE_ERROR;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -3406,7 +3414,7 @@ void byte_queue_write_fmt2(ByteQueue *queue,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len > dst.len) {
|
if ((size_t) len > dst.len) {
|
||||||
byte_queue_write_ack(queue, 0);
|
byte_queue_write_ack(queue, 0);
|
||||||
byte_queue_write_setmincap(queue, len+1);
|
byte_queue_write_setmincap(queue, len+1);
|
||||||
dst = byte_queue_write_buf(queue);
|
dst = byte_queue_write_buf(queue);
|
||||||
@@ -3447,7 +3455,7 @@ void byte_queue_patch(ByteQueue *queue, ByteQueueOffset off,
|
|||||||
assert(len <= queue->used - (off - queue->curs));
|
assert(len <= queue->used - (off - queue->curs));
|
||||||
|
|
||||||
// Perform the patch
|
// Perform the patch
|
||||||
uint8_t *dst = queue->data + queue->head + (off - queue->curs);
|
char *dst = queue->data + queue->head + (off - queue->curs);
|
||||||
memcpy(dst, src, len);
|
memcpy(dst, src, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4855,6 +4863,20 @@ void http_response_builder_status(HTTP_ResponseBuilder builder, int status)
|
|||||||
conn->state = HTTP_SERVER_CONN_WAIT_HEADER;
|
conn->state = HTTP_SERVER_CONN_WAIT_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_header_valid(HTTP_String str)
|
||||||
|
{
|
||||||
|
bool has_colon = false;
|
||||||
|
for (int i = 0; i < str.len; i++) {
|
||||||
|
char c = str.ptr[i];
|
||||||
|
if (c == ':')
|
||||||
|
has_colon = true;
|
||||||
|
// Reject control characters (especially \r and \n)
|
||||||
|
if (c < 0x20 && c != '\t')
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return has_colon;
|
||||||
|
}
|
||||||
|
|
||||||
void http_response_builder_header(HTTP_ResponseBuilder builder, HTTP_String str)
|
void http_response_builder_header(HTTP_ResponseBuilder builder, HTTP_String str)
|
||||||
{
|
{
|
||||||
HTTP_ServerConn *conn = builder_to_conn(builder);
|
HTTP_ServerConn *conn = builder_to_conn(builder);
|
||||||
@@ -4864,19 +4886,9 @@ void http_response_builder_header(HTTP_ResponseBuilder builder, HTTP_String str)
|
|||||||
if (conn->state != HTTP_SERVER_CONN_WAIT_HEADER)
|
if (conn->state != HTTP_SERVER_CONN_WAIT_HEADER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Validate header: must contain a colon and no control characters
|
// Header must contain a colon and no control characters
|
||||||
// (to prevent HTTP response splitting attacks)
|
// to prevent HTTP response splitting attacks
|
||||||
bool has_colon = false;
|
if (!is_header_valid(str)) return; // Silently drop it
|
||||||
for (int i = 0; i < str.len; i++) {
|
|
||||||
char c = str.ptr[i];
|
|
||||||
if (c == ':')
|
|
||||||
has_colon = true;
|
|
||||||
// Reject control characters (especially \r and \n)
|
|
||||||
if (c < 0x20 && c != '\t')
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!has_colon)
|
|
||||||
return;
|
|
||||||
|
|
||||||
byte_queue_write(&conn->output, str.ptr, str.len);
|
byte_queue_write(&conn->output, str.ptr, str.len);
|
||||||
byte_queue_write(&conn->output, "\r\n", 2);
|
byte_queue_write(&conn->output, "\r\n", 2);
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ char *http_strerror(int code);
|
|||||||
#define HTTP_STR(X) ((HTTP_String) {(X), sizeof(X)-1})
|
#define HTTP_STR(X) ((HTTP_String) {(X), sizeof(X)-1})
|
||||||
|
|
||||||
// Returns the number of items of a static array.
|
// Returns the number of items of a static array.
|
||||||
#define HTTP_COUNT(X) (sizeof(X) / sizeof((X)[0]))
|
#define HTTP_COUNT(X) (int) (sizeof(X) / sizeof((X)[0]))
|
||||||
|
|
||||||
// Macro to unpack an HTTP_String into its length and pointer components.
|
// Macro to unpack an HTTP_String into its length and pointer components.
|
||||||
// Useful for passing HTTP_String to printf-style functions with "%.*s" format.
|
// Useful for passing HTTP_String to printf-style functions with "%.*s" format.
|
||||||
@@ -382,7 +382,7 @@ int server_secure_context_add_certificate(ServerSecureContext *ctx,
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define NATIVE_SOCKET SOCKET
|
#define NATIVE_SOCKET SOCKET
|
||||||
#define NATIVE_SOCKET_INVALID SOCKET_ERROR
|
#define NATIVE_SOCKET_INVALID INVALID_SOCKET
|
||||||
#define CLOSE_NATIVE_SOCKET closesocket
|
#define CLOSE_NATIVE_SOCKET closesocket
|
||||||
#else
|
#else
|
||||||
#define NATIVE_SOCKET int
|
#define NATIVE_SOCKET int
|
||||||
@@ -688,19 +688,19 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t *ptr;
|
char *ptr;
|
||||||
size_t len;
|
size_t len;
|
||||||
} ByteView;
|
} ByteView;
|
||||||
|
|
||||||
// Fields are for internal use only
|
// Fields are for internal use only
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t curs;
|
uint64_t curs;
|
||||||
uint8_t* data;
|
char* data;
|
||||||
uint32_t head;
|
uint32_t head;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint32_t used;
|
uint32_t used;
|
||||||
uint32_t limit;
|
uint32_t limit;
|
||||||
uint8_t* read_target;
|
char* read_target;
|
||||||
uint32_t read_target_size;
|
uint32_t read_target_size;
|
||||||
int flags;
|
int flags;
|
||||||
} ByteQueue;
|
} ByteQueue;
|
||||||
|
|||||||
+1
-1
@@ -71,7 +71,7 @@ char *http_strerror(int code);
|
|||||||
#define HTTP_STR(X) ((HTTP_String) {(X), sizeof(X)-1})
|
#define HTTP_STR(X) ((HTTP_String) {(X), sizeof(X)-1})
|
||||||
|
|
||||||
// Returns the number of items of a static array.
|
// Returns the number of items of a static array.
|
||||||
#define HTTP_COUNT(X) (sizeof(X) / sizeof((X)[0]))
|
#define HTTP_COUNT(X) (int) (sizeof(X) / sizeof((X)[0]))
|
||||||
|
|
||||||
// Macro to unpack an HTTP_String into its length and pointer components.
|
// Macro to unpack an HTTP_String into its length and pointer components.
|
||||||
// Useful for passing HTTP_String to printf-style functions with "%.*s" format.
|
// Useful for passing HTTP_String to printf-style functions with "%.*s" format.
|
||||||
|
|||||||
+3
-3
@@ -179,7 +179,7 @@ int byte_queue_write_setmincap(ByteQueue *queue, uint32_t mincap)
|
|||||||
if (size > queue->limit)
|
if (size > queue->limit)
|
||||||
size = queue->limit;
|
size = queue->limit;
|
||||||
|
|
||||||
uint8_t *data = malloc(size);
|
char *data = malloc(size);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
queue->flags |= BYTE_QUEUE_ERROR;
|
queue->flags |= BYTE_QUEUE_ERROR;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -236,7 +236,7 @@ void byte_queue_write_fmt2(ByteQueue *queue,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len > dst.len) {
|
if ((size_t) len > dst.len) {
|
||||||
byte_queue_write_ack(queue, 0);
|
byte_queue_write_ack(queue, 0);
|
||||||
byte_queue_write_setmincap(queue, len+1);
|
byte_queue_write_setmincap(queue, len+1);
|
||||||
dst = byte_queue_write_buf(queue);
|
dst = byte_queue_write_buf(queue);
|
||||||
@@ -277,7 +277,7 @@ void byte_queue_patch(ByteQueue *queue, ByteQueueOffset off,
|
|||||||
assert(len <= queue->used - (off - queue->curs));
|
assert(len <= queue->used - (off - queue->curs));
|
||||||
|
|
||||||
// Perform the patch
|
// Perform the patch
|
||||||
uint8_t *dst = queue->data + queue->head + (off - queue->curs);
|
char *dst = queue->data + queue->head + (off - queue->curs);
|
||||||
memcpy(dst, src, len);
|
memcpy(dst, src, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -15,19 +15,19 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t *ptr;
|
char *ptr;
|
||||||
size_t len;
|
size_t len;
|
||||||
} ByteView;
|
} ByteView;
|
||||||
|
|
||||||
// Fields are for internal use only
|
// Fields are for internal use only
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint64_t curs;
|
uint64_t curs;
|
||||||
uint8_t* data;
|
char* data;
|
||||||
uint32_t head;
|
uint32_t head;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint32_t used;
|
uint32_t used;
|
||||||
uint32_t limit;
|
uint32_t limit;
|
||||||
uint8_t* read_target;
|
char* read_target;
|
||||||
uint32_t read_target_size;
|
uint32_t read_target_size;
|
||||||
int flags;
|
int flags;
|
||||||
} ByteQueue;
|
} ByteQueue;
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ void client_secure_context_free(ClientSecureContext *ctx)
|
|||||||
{
|
{
|
||||||
#ifdef HTTPS_ENABLED
|
#ifdef HTTPS_ENABLED
|
||||||
SSL_CTX_free(ctx->p);
|
SSL_CTX_free(ctx->p);
|
||||||
|
#else
|
||||||
|
(void) ctx;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-13
@@ -415,6 +415,20 @@ void http_response_builder_status(HTTP_ResponseBuilder builder, int status)
|
|||||||
conn->state = HTTP_SERVER_CONN_WAIT_HEADER;
|
conn->state = HTTP_SERVER_CONN_WAIT_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_header_valid(HTTP_String str)
|
||||||
|
{
|
||||||
|
bool has_colon = false;
|
||||||
|
for (int i = 0; i < str.len; i++) {
|
||||||
|
char c = str.ptr[i];
|
||||||
|
if (c == ':')
|
||||||
|
has_colon = true;
|
||||||
|
// Reject control characters (especially \r and \n)
|
||||||
|
if (c < 0x20 && c != '\t')
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return has_colon;
|
||||||
|
}
|
||||||
|
|
||||||
void http_response_builder_header(HTTP_ResponseBuilder builder, HTTP_String str)
|
void http_response_builder_header(HTTP_ResponseBuilder builder, HTTP_String str)
|
||||||
{
|
{
|
||||||
HTTP_ServerConn *conn = builder_to_conn(builder);
|
HTTP_ServerConn *conn = builder_to_conn(builder);
|
||||||
@@ -424,19 +438,9 @@ void http_response_builder_header(HTTP_ResponseBuilder builder, HTTP_String str)
|
|||||||
if (conn->state != HTTP_SERVER_CONN_WAIT_HEADER)
|
if (conn->state != HTTP_SERVER_CONN_WAIT_HEADER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Validate header: must contain a colon and no control characters
|
// Header must contain a colon and no control characters
|
||||||
// (to prevent HTTP response splitting attacks)
|
// to prevent HTTP response splitting attacks
|
||||||
bool has_colon = false;
|
if (!is_header_valid(str)) return; // Silently drop it
|
||||||
for (int i = 0; i < str.len; i++) {
|
|
||||||
char c = str.ptr[i];
|
|
||||||
if (c == ':')
|
|
||||||
has_colon = true;
|
|
||||||
// Reject control characters (especially \r and \n)
|
|
||||||
if (c < 0x20 && c != '\t')
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!has_colon)
|
|
||||||
return;
|
|
||||||
|
|
||||||
byte_queue_write(&conn->output, str.ptr, str.len);
|
byte_queue_write(&conn->output, str.ptr, str.len);
|
||||||
byte_queue_write(&conn->output, "\r\n", 2);
|
byte_queue_write(&conn->output, "\r\n", 2);
|
||||||
|
|||||||
+13
-7
@@ -297,6 +297,7 @@ static bool is_secure(Socket *s)
|
|||||||
return s->server_secure_context != NULL
|
return s->server_secure_context != NULL
|
||||||
|| s->client_secure_context != NULL;
|
|| s->client_secure_context != NULL;
|
||||||
#else
|
#else
|
||||||
|
(void) s;
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -690,7 +691,6 @@ int socket_manager_wakeup(SocketManager *sm)
|
|||||||
// NOTE: It's assumed send/write operate atomically
|
// NOTE: It's assumed send/write operate atomically
|
||||||
// on The descriptor.
|
// on The descriptor.
|
||||||
char byte = 1;
|
char byte = 1;
|
||||||
int ret = 0;
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (send(sm->signal_sock, &byte, 1, 0) < 0)
|
if (send(sm->signal_sock, &byte, 1, 0) < 0)
|
||||||
return HTTP_ERROR_UNSPECIFIED;
|
return HTTP_ERROR_UNSPECIFIED;
|
||||||
@@ -803,10 +803,6 @@ int socket_manager_translate_events(
|
|||||||
if (sm->num_used == sm->max_used)
|
if (sm->num_used == sm->max_used)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Determine whether the event came from
|
|
||||||
// the encrypted listener or not.
|
|
||||||
bool secure = (reg.polled[i].fd == sm->secure_sock);
|
|
||||||
|
|
||||||
Socket *s = sm->sockets;
|
Socket *s = sm->sockets;
|
||||||
while (s->state != SOCKET_STATE_FREE) {
|
while (s->state != SOCKET_STATE_FREE) {
|
||||||
s++;
|
s++;
|
||||||
@@ -827,6 +823,10 @@ int socket_manager_translate_events(
|
|||||||
s->events = 0;
|
s->events = 0;
|
||||||
s->user = NULL;
|
s->user = NULL;
|
||||||
#ifdef HTTPS_ENABLED
|
#ifdef HTTPS_ENABLED
|
||||||
|
// Determine whether the event came from
|
||||||
|
// the encrypted listener or not.
|
||||||
|
bool secure = (reg.polled[i].fd == sm->secure_sock);
|
||||||
|
|
||||||
s->ssl = NULL;
|
s->ssl = NULL;
|
||||||
s->server_secure_context = NULL;
|
s->server_secure_context = NULL;
|
||||||
s->client_secure_context = NULL;
|
s->client_secure_context = NULL;
|
||||||
@@ -1066,6 +1066,8 @@ int socket_connect(SocketManager *sm, int num_targets,
|
|||||||
s->client_secure_context = &sm->client_secure_context;
|
s->client_secure_context = &sm->client_secure_context;
|
||||||
s->dont_verify_cert = dont_verify_cert;
|
s->dont_verify_cert = dont_verify_cert;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
(void) dont_verify_cert;
|
||||||
#endif
|
#endif
|
||||||
sm->num_used++;
|
sm->num_used++;
|
||||||
|
|
||||||
@@ -1139,6 +1141,9 @@ int socket_recv(SocketManager *sm, SocketHandle handle,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
#else
|
||||||
|
// Unreachable
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1187,13 +1192,15 @@ int socket_send(SocketManager *sm, SocketHandle handle,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
#else
|
||||||
|
// Unreachable
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void socket_close(SocketManager *sm, SocketHandle handle)
|
void socket_close(SocketManager *sm, SocketHandle handle)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
Socket *s = handle_to_socket(sm, handle);
|
Socket *s = handle_to_socket(sm, handle);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -1224,7 +1231,6 @@ void socket_set_user(SocketManager *sm, SocketHandle handle, void *user)
|
|||||||
|
|
||||||
bool socket_ready(SocketManager *sm, SocketHandle handle)
|
bool socket_ready(SocketManager *sm, SocketHandle handle)
|
||||||
{
|
{
|
||||||
bool ready = false;
|
|
||||||
Socket *s = handle_to_socket(sm, handle);
|
Socket *s = handle_to_socket(sm, handle);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+1
-1
@@ -50,7 +50,7 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define NATIVE_SOCKET SOCKET
|
#define NATIVE_SOCKET SOCKET
|
||||||
#define NATIVE_SOCKET_INVALID SOCKET_ERROR
|
#define NATIVE_SOCKET_INVALID INVALID_SOCKET
|
||||||
#define CLOSE_NATIVE_SOCKET closesocket
|
#define CLOSE_NATIVE_SOCKET closesocket
|
||||||
#else
|
#else
|
||||||
#define NATIVE_SOCKET int
|
#define NATIVE_SOCKET int
|
||||||
|
|||||||
Reference in New Issue
Block a user