added qse_shutsckhnd()
This commit is contained in:
parent
e8cef98c87
commit
2e6765e4ba
@ -55,6 +55,14 @@
|
|||||||
typedef int qse_sck_len_t;
|
typedef int qse_sck_len_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum qse_shutsckhnd_how_t
|
||||||
|
{
|
||||||
|
QSE_SHUTSCKHND_R = 0,
|
||||||
|
QSE_SHUTSCKHND_W = 1,
|
||||||
|
QSE_SHUTSCKHND_RW = 2
|
||||||
|
};
|
||||||
|
typedef enum qse_shutsckhnd_how_t qse_shutsckhnd_how_t;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -67,6 +75,12 @@ QSE_EXPORT void qse_closesckhnd (
|
|||||||
qse_sck_hnd_t handle
|
qse_sck_hnd_t handle
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
QSE_EXPORT void qse_shutsckhnd (
|
||||||
|
qse_sck_hnd_t handle,
|
||||||
|
qse_shutsckhnd_how_t how
|
||||||
|
);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -51,6 +51,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(SHUT_RDWR)
|
||||||
|
# define SHUT_RDWR 2
|
||||||
|
#endif
|
||||||
|
|
||||||
QSE_INLINE int qse_isvalidsckhnd (qse_sck_hnd_t handle)
|
QSE_INLINE int qse_isvalidsckhnd (qse_sck_hnd_t handle)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
@ -80,6 +84,22 @@ QSE_INLINE void qse_closesckhnd (qse_sck_hnd_t handle)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSE_INLINE void qse_shutsckhnd (qse_sck_hnd_t handle, qse_shutsckhnd_how_t how)
|
||||||
|
{
|
||||||
|
static int how_v[] = { SHUT_RD, SHUT_WR, SHUT_RDWR };
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
shutdown (handle, how_v[how]);
|
||||||
|
#elif defined(__OS2__)
|
||||||
|
shutdown (handle, how_v[how]);
|
||||||
|
#elif defined(__DOS__)
|
||||||
|
/* TODO: */
|
||||||
|
#else
|
||||||
|
shutdown (handle, how_v[how]);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
qse_sck_hnd_t
|
qse_sck_hnd_t
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ static QSE_INLINE qse_ssize_t __send_file (
|
|||||||
|
|
||||||
qse_ssize_t ret;
|
qse_ssize_t ret;
|
||||||
qse_fio_hnd_t fh;
|
qse_fio_hnd_t fh;
|
||||||
|
|
||||||
fh = qse_fio_gethandle (in_fd.ptr);
|
fh = qse_fio_gethandle (in_fd.ptr);
|
||||||
ret = sendfile64 (out_fd, fh, offset, count);
|
ret = sendfile64 (out_fd, fh, offset, count);
|
||||||
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
|
if (ret <= -1) qse_httpd_seterrnum (httpd, SKERR_TO_ERRNUM());
|
||||||
@ -461,14 +461,14 @@ on failure xfer != ret.
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
qse_mchar_t buf[MAX_SEND_SIZE];
|
qse_mchar_t buf[MAX_SEND_SIZE]; /* TODO: move this into client, server, or httpd */
|
||||||
qse_ssize_t ret;
|
qse_ssize_t ret;
|
||||||
qse_foff_t foff;
|
qse_foff_t foff;
|
||||||
|
|
||||||
if (offset && (foff = qse_fio_seek (in_fd.ptr, *offset, QSE_FIO_BEGIN)) != *offset)
|
if (offset && (foff = qse_fio_seek (in_fd.ptr, *offset, QSE_FIO_BEGIN)) != *offset)
|
||||||
{
|
{
|
||||||
if (foff == (qse_foff_t)-1)
|
if (foff == (qse_foff_t)-1)
|
||||||
qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(in_fd.ptr)));
|
qse_httpd_seterrnum (httpd, fioerr_to_errnum(qse_fio_geterrnum(in_fd.ptr)));
|
||||||
else
|
else
|
||||||
qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR);
|
qse_httpd_seterrnum (httpd, QSE_HTTPD_ESYSERR);
|
||||||
return (qse_ssize_t)-1;
|
return (qse_ssize_t)-1;
|
||||||
@ -1829,36 +1829,16 @@ static int dir_read (qse_httpd_t* httpd, qse_ubi_t handle, qse_httpd_dirent_t* d
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------- */
|
||||||
#if !defined(SHUT_RDWR)
|
|
||||||
# define SHUT_RDWR 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void client_close (qse_httpd_t* httpd, qse_httpd_client_t* client)
|
static void client_close (qse_httpd_t* httpd, qse_httpd_client_t* client)
|
||||||
{
|
{
|
||||||
|
qse_shutsckhnd (client->handle.i, QSE_SHUTSCKHND_RW);
|
||||||
#if defined(_WIN32)
|
|
||||||
shutdown (client->handle.i, SHUT_RDWR);
|
|
||||||
#elif defined(__OS2__)
|
|
||||||
shutdown (client->handle.i, SHUT_RDWR);
|
|
||||||
#elif defined(__DOS__)
|
|
||||||
/* TODO: */
|
|
||||||
#else
|
|
||||||
shutdown (client->handle.i, SHUT_RDWR);
|
|
||||||
#endif
|
|
||||||
qse_closesckhnd (client->handle.i);
|
qse_closesckhnd (client->handle.i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void client_shutdown (qse_httpd_t* httpd, qse_httpd_client_t* client)
|
static void client_shutdown (qse_httpd_t* httpd, qse_httpd_client_t* client)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
qse_shutsckhnd (client->handle.i, QSE_SHUTSCKHND_RW);
|
||||||
shutdown (client->handle.i, SHUT_RDWR);
|
|
||||||
#elif defined(__OS2__)
|
|
||||||
shutdown (client->handle.i, SHUT_RDWR);
|
|
||||||
#elif defined(__DOS__)
|
|
||||||
/* TODO: */
|
|
||||||
#else
|
|
||||||
shutdown (client->handle.i, SHUT_RDWR);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static qse_ssize_t client_recv (
|
static qse_ssize_t client_recv (
|
||||||
@ -1954,7 +1934,6 @@ static qse_ssize_t client_sendfile (
|
|||||||
|
|
||||||
static int client_accepted (qse_httpd_t* httpd, qse_httpd_client_t* client)
|
static int client_accepted (qse_httpd_t* httpd, qse_httpd_client_t* client)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (client->status & QSE_HTTPD_CLIENT_SECURE)
|
if (client->status & QSE_HTTPD_CLIENT_SECURE)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_SSL)
|
#if defined(HAVE_SSL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user