From 2c5d85f55f6ce62b30aabb8bd1aa12772a313cbc Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 30 Oct 2014 16:29:48 +0000 Subject: [PATCH] fixed a bug in qse_httpd_addhnd(). exported qse_httpd_entaskerrorwithmvk() --- qse/include/qse/http/httpd.h | 10 ++++++++++ qse/lib/http/httpd-cgi.c | 4 ++-- qse/lib/http/httpd-file.c | 10 +++++----- qse/lib/http/httpd-proxy.c | 6 +++--- qse/lib/http/httpd-task.c | 6 ++++-- qse/lib/http/httpd.c | 2 +- qse/lib/http/httpd.h | 10 ---------- 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/qse/include/qse/http/httpd.h b/qse/include/qse/http/httpd.h index d9eb1459..98135938 100644 --- a/qse/include/qse/http/httpd.h +++ b/qse/include/qse/http/httpd.h @@ -1185,6 +1185,16 @@ QSE_EXPORT qse_httpd_task_t* qse_httpd_entaskerror ( qse_htre_t* req ); +QSE_EXPORT qse_httpd_task_t* qse_httpd_entaskerrorwithmvk ( + qse_httpd_t* httpd, + qse_httpd_client_t* client, + qse_httpd_task_t* pred, + int code, + qse_http_method_t method, + const qse_http_version_t* version, + int keepalive +); + QSE_EXPORT qse_httpd_task_t* qse_httpd_entaskcontinue ( qse_httpd_t* httpd, qse_httpd_client_t* client, diff --git a/qse/lib/http/httpd-cgi.c b/qse/lib/http/httpd-cgi.c index f08b9973..219676e0 100644 --- a/qse/lib/http/httpd-cgi.c +++ b/qse/lib/http/httpd-cgi.c @@ -1431,7 +1431,7 @@ printf ("task_main_cgi_2 trigger[0].mask=%d trigger[1].mask=%d cmask=%d\n", return 1; oops: - return (qse_httpd_entask_error (httpd, client, task, 500, cgi->method, &cgi->version, cgi->keepalive) == QSE_NULL)? -1: 0; + return (qse_httpd_entaskerrorwithmvk (httpd, client, task, 500, cgi->method, &cgi->version, cgi->keepalive) == QSE_NULL)? -1: 0; } static int task_main_cgi ( @@ -1595,7 +1595,7 @@ oops: cgi->script_htrd = QSE_NULL; } - return (qse_httpd_entask_error ( + return (qse_httpd_entaskerrorwithmvk ( httpd, client, task, http_errnum, cgi->method, &cgi->version, cgi->keepalive) == QSE_NULL)? -1: 0; } diff --git a/qse/lib/http/httpd-file.c b/qse/lib/http/httpd-file.c index a15ab2bc..da8bab8d 100644 --- a/qse/lib/http/httpd-file.c +++ b/qse/lib/http/httpd-file.c @@ -191,7 +191,7 @@ static QSE_INLINE int task_main_getfile ( int http_errnum; http_errnum = (httpd->errnum == QSE_HTTPD_ENOENT)? 404: (httpd->errnum == QSE_HTTPD_EACCES)? 403: 500; - x = qse_httpd_entask_error ( + x = qse_httpd_entaskerrorwithmvk ( httpd, client, x, http_errnum, file->method, &file->version, file->keepalive); goto no_file_send; @@ -203,7 +203,7 @@ static QSE_INLINE int task_main_getfile ( int http_errnum; http_errnum = (httpd->errnum == QSE_HTTPD_ENOENT)? 404: (httpd->errnum == QSE_HTTPD_EACCES)? 403: 500; - x = qse_httpd_entask_error ( + x = qse_httpd_entaskerrorwithmvk ( httpd, client, x, http_errnum, file->method, &file->version, file->keepalive); goto no_file_send; @@ -226,7 +226,7 @@ static QSE_INLINE int task_main_getfile ( if (file->u.get.range.from >= st.size) { - x = qse_httpd_entask_error ( + x = qse_httpd_entaskerrorwithmvk ( httpd, client, x, 416, file->method, &file->version, file->keepalive); goto no_file_send; } @@ -491,7 +491,7 @@ static int task_main_putfile_2 ( /* snatching is over. writing error may have occurred as well. * file->u.put.status should hold a proper status code */ - if (qse_httpd_entask_error ( + if (qse_httpd_entaskerrorwithmvk ( httpd, client, task, file->u.put.status, file->method, &file->version, file->keepalive) == QSE_NULL) return -1; return 0; /* no more data to read. task over */ @@ -516,7 +516,7 @@ static int task_main_putfile ( * note: if initialization error occurred and there is contents for the * client to send, this reply may get to the client before it finishes * sending the contents. */ - if (qse_httpd_entask_error ( + if (qse_httpd_entaskerrorwithmvk ( httpd, client, task, file->u.put.status, file->method, &file->version, file->keepalive) == QSE_NULL) return -1; return 0; /* task over */ diff --git a/qse/lib/http/httpd-proxy.c b/qse/lib/http/httpd-proxy.c index bb782543..fd0d562c 100644 --- a/qse/lib/http/httpd-proxy.c +++ b/qse/lib/http/httpd-proxy.c @@ -1854,7 +1854,7 @@ qse_printf (QSE_T("TRAILING DATA=%d, [%hs]\n"), (int)QSE_MBS_LEN(proxy->res), QS oops: if (proxy->resflags & PROXY_RES_EVER_SENTBACK) return -1; - return (qse_httpd_entask_error (httpd, client, task, http_errnum, proxy->method, &proxy->version, proxy->keepalive) == QSE_NULL)? -1: 0; + return (qse_httpd_entaskerrorwithmvk (httpd, client, task, http_errnum, proxy->method, &proxy->version, proxy->keepalive) == QSE_NULL)? -1: 0; } static int task_main_proxy_1 ( @@ -1947,7 +1947,7 @@ static int task_main_proxy_1 ( return 1; oops: - return (qse_httpd_entask_error (httpd, client, task, http_errnum, proxy->method, &proxy->version, proxy->keepalive) == QSE_NULL)? -1: 0; + return (qse_httpd_entaskerrorwithmvk (httpd, client, task, http_errnum, proxy->method, &proxy->version, proxy->keepalive) == QSE_NULL)? -1: 0; } static void on_peer_name_resolved (qse_httpd_t* httpd, const qse_mchar_t* name, const qse_nwad_t* nwad, void* ctx) @@ -2406,7 +2406,7 @@ oops: proxy->peer_htrd = QSE_NULL; } - return (qse_httpd_entask_error ( + return (qse_httpd_entaskerrorwithmvk ( httpd, client, task, http_errnum, proxy->method, &proxy->version, proxy->keepalive) == QSE_NULL)? -1: 0; } diff --git a/qse/lib/http/httpd-task.c b/qse/lib/http/httpd-task.c index 12419ebc..eefff058 100644 --- a/qse/lib/http/httpd-task.c +++ b/qse/lib/http/httpd-task.c @@ -228,10 +228,12 @@ qse_httpd_task_t* qse_httpd_entask_status ( } /*------------------------------------------------------------------------*/ -qse_httpd_task_t* qse_httpd_entask_error ( +qse_httpd_task_t* qse_httpd_entaskerrorwithmvk ( qse_httpd_t* httpd, qse_httpd_client_t* client, qse_httpd_task_t* pred, int code, - qse_http_method_t method, const qse_http_version_t* version, int keepalive) + qse_http_method_t method, + const qse_http_version_t* version, + int keepalive) { return qse_httpd_entask_status (httpd, client, pred, code, QSE_NULL, method, version, keepalive); } diff --git a/qse/lib/http/httpd.c b/qse/lib/http/httpd.c index 32c8a61c..9ee5d35b 100644 --- a/qse/lib/http/httpd.c +++ b/qse/lib/http/httpd.c @@ -906,7 +906,7 @@ int qse_httpd_addhnd (qse_httpd_t* httpd, qse_httpd_hnd_t handle, int mask, qse_ /* qse_httpd_loop() opens the multiplexer. you can call this function from * preloop/postloop hooks only. but calling it from postloop hooks is * useless. */ - return httpd->opt.scb.mux.addhnd (httpd, httpd->mux, handle, QSE_HTTPD_MUX_READ, mate); + return httpd->opt.scb.mux.addhnd (httpd, httpd->mux, handle, mask, mate); } int qse_httpd_delhnd (qse_httpd_t* httpd, qse_httpd_hnd_t handle) diff --git a/qse/lib/http/httpd.h b/qse/lib/http/httpd.h index ba829245..357a6707 100644 --- a/qse/lib/http/httpd.h +++ b/qse/lib/http/httpd.h @@ -132,16 +132,6 @@ qse_httpd_task_t* qse_httpd_entask_status ( int keepalive ); -qse_httpd_task_t* qse_httpd_entask_error ( - qse_httpd_t* httpd, - qse_httpd_client_t* client, - qse_httpd_task_t* pred, - int code, - qse_http_method_t method, - const qse_http_version_t* version, - int keepalive -); - qse_httpd_task_t* qse_httpd_entask_nomod ( qse_httpd_t* httpd, qse_httpd_client_t* client,