diff --git a/lib/hio-http.h b/lib/hio-http.h index 6290997..5d89502 100644 --- a/lib/hio-http.h +++ b/lib/hio-http.h @@ -100,8 +100,9 @@ struct hio_svc_htts_task_t HIO_SVC_HTTS_TASK_HEADER; }; + #define HIO_SVC_HTTS_TASK_REF(task, var) do { (var) = (task); ++(task)->task_refcnt; } while(0) -#define HIO_SVC_HTTS_TASK_UNREF(task_var) do { if (--(task_var)->task_refcnt == 0) { hio_svc_htts_task_t* __task_tmp = (task_var); (task_var) = HIO_NULL; hio_svc_htts_task_kill(__task_tmp); } else { (task_var) = HIO_NULL; } } while(0) +#define HIO_SVC_HTTS_TASK_UNREF(task_var) do { if (--(task_var)->task_refcnt == 0) { hio_svc_htts_task_t* __task_tmp = (hio_svc_htts_task_t*)(task_var); (task_var) = HIO_NULL; hio_svc_htts_task_kill(__task_tmp); } else { (task_var) = HIO_NULL; } } while(0) /* -------------------------------------------------------------- */ diff --git a/lib/hio-skad.h b/lib/hio-skad.h index 3b27510..2019a90 100644 --- a/lib/hio-skad.h +++ b/lib/hio-skad.h @@ -233,7 +233,7 @@ HIO_EXPORT void hio_skad_set_chan ( ); HIO_EXPORT hio_oow_t hio_skad_get_ipad_bytes ( - hio_skad_t* skad, + const hio_skad_t* skad, void* buf, hio_oow_t len ); diff --git a/lib/http-cgi.c b/lib/http-cgi.c index 5cee647..e44a3a6 100644 --- a/lib/http-cgi.c +++ b/lib/http-cgi.c @@ -1022,7 +1022,7 @@ int hio_svc_htts_docgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r cgi->peer = hio_dev_pro_make(hio, HIO_SIZEOF(*peer_xtn), &mi); if (HIO_UNLIKELY(!cgi->peer)) goto oops; peer_xtn = hio_dev_pro_getxtn(cgi->peer); - HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_t*)cgi, peer_xtn->cgi); /* peer->cgi in pro = cgi */ + HIO_SVC_HTTS_TASK_REF (cgi, peer_xtn->cgi); /* peer->cgi in pro = cgi */ cgi->peer_htrd = hio_htrd_open(hio, HIO_SIZEOF(*peer_xtn)); if (HIO_UNLIKELY(!cgi->peer_htrd)) goto oops; @@ -1030,7 +1030,7 @@ int hio_svc_htts_docgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r hio_htrd_setrecbs (cgi->peer_htrd, &peer_htrd_recbs); peer_xtn = hio_htrd_getxtn(cgi->peer_htrd); - HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_t*)cgi, peer_xtn->cgi); /* peer->cgi in htrd = cgi */ + HIO_SVC_HTTS_TASK_REF (cgi, peer_xtn->cgi); /* peer->cgi in htrd = cgi */ #if !defined(CGI_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH) if (cgi->req_content_length_unlimited) @@ -1129,7 +1129,7 @@ int hio_svc_htts_docgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r if (hio_dev_sck_read(csck, !(cgi->over & CGI_OVER_READ_FROM_CLIENT)) <= -1) goto oops; hio_freemem (hio, fc.actual_script); - HIO_SVC_HTTS_TASKL_APPEND_TASK (&htts->task, cgi); + HIO_SVC_HTTS_TASKL_APPEND_TASK (&htts->task, (hio_svc_htts_task_t*)cgi); return 0; oops: diff --git a/lib/http-fcgi.c b/lib/http-fcgi.c index 9a7a3a9..e09d9b2 100644 --- a/lib/http-fcgi.c +++ b/lib/http-fcgi.c @@ -2,6 +2,7 @@ #include #include #include +#include #define FCGI_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH @@ -526,7 +527,7 @@ oops: return 0; } -static int fcgi_peer_on_untie (hio_svc_fcgic_sess_t* peer, void* ctx) +static void fcgi_peer_on_untie (hio_svc_fcgic_sess_t* peer, void* ctx) { fcgi_t* fcgi = (fcgi_t*)ctx; if (fcgi->peer) fcgi->peer = HIO_NULL; /* in case this untie event originates from the fcgi client itself */ @@ -795,7 +796,7 @@ int hio_svc_htts_dofcgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* hio_htrd_setoption (fcgi->peer_htrd, HIO_HTRD_SKIP_INITIAL_LINE | HIO_HTRD_RESPONSE); hio_htrd_setrecbs (fcgi->peer_htrd, &peer_htrd_recbs); pxtn = hio_htrd_getxtn(fcgi->peer_htrd); - HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_t*)fcgi, pxtn->fcgi); /* peer->fcgi in htrd = fcgi */ + HIO_SVC_HTTS_TASK_REF (fcgi, pxtn->fcgi); /* peer->fcgi in htrd = fcgi */ /* create a session in in the fcgi client service */ fcgi->peer = hio_svc_fcgic_tie(htts->fcgic, fcgis_addr, fcgi_peer_on_read, fcgi_peer_on_untie, fcgi); @@ -903,7 +904,7 @@ int hio_svc_htts_dofcgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* /* TODO: store current input watching state and use it when destroying the fcgi data */ if (hio_dev_sck_read(csck, !(fcgi->over & FCGI_OVER_READ_FROM_CLIENT)) <= -1) goto oops; - HIO_SVC_HTTS_TASKL_APPEND_TASK (&htts->task, fcgi); + HIO_SVC_HTTS_TASKL_APPEND_TASK (&htts->task, (hio_svc_htts_task_t*)fcgi); return 0; oops: diff --git a/lib/http-file.c b/lib/http-file.c index 55f1d08..2215d95 100644 --- a/lib/http-file.c +++ b/lib/http-file.c @@ -995,7 +995,7 @@ int hio_svc_htts_dofile (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* if (hio_dev_sck_read(csck, !(file->over & FILE_OVER_READ_FROM_CLIENT)) <= -1) goto oops; hio_freemem (hio, actual_file); - HIO_SVC_HTTS_TASKL_APPEND_TASK (&htts->task, file); + HIO_SVC_HTTS_TASKL_APPEND_TASK (&htts->task, (hio_svc_htts_task_t*)file); return 0; oops: diff --git a/lib/http-thr.c b/lib/http-thr.c index b672a36..572f333 100644 --- a/lib/http-thr.c +++ b/lib/http-thr.c @@ -209,7 +209,7 @@ static int thr_task_write_to_peer (thr_task_t* thr_task, const void* data, hio_i /* TODO: check if it's already finished or something.. */ if (thr_task->num_pending_writes_to_peer > THR_TASK_PENDING_IO_THRESHOLD) { - if (thr_task->csck, hio_dev_sck_read(thr_task->csck, 0) <= -1) return -1; + if (thr_task->csck && hio_dev_sck_read(thr_task->csck, 0) <= -1) return -1; } } return 0; @@ -957,7 +957,7 @@ int hio_svc_htts_dothr (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r /* attach the thr task to the peer thread device */ thr_peer = hio_dev_thr_getxtn(thr_task->peer); - HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_t*)thr_task, thr_peer->task); + HIO_SVC_HTTS_TASK_REF (thr_task, thr_peer->task); thr_task->peer_htrd = hio_htrd_open(hio, HIO_SIZEOF(*thr_peer)); if (HIO_UNLIKELY(!thr_task->peer_htrd)) goto oops; @@ -966,7 +966,7 @@ int hio_svc_htts_dothr (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r /* attach the thr task to the htrd parser set on the peer thread device */ thr_peer = hio_htrd_getxtn(thr_task->peer_htrd); - HIO_SVC_HTTS_TASK_REF ((hio_svc_htts_task_t*)thr_task, thr_peer->task); + HIO_SVC_HTTS_TASK_REF (thr_task, thr_peer->task); #if !defined(THR_ALLOW_UNLIMITED_REQ_CONTENT_LENGTH) if (thr_task->req_content_length_unlimited) @@ -1054,7 +1054,7 @@ int hio_svc_htts_dothr (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r /* TODO: store current input watching state and use it when destroying the thr_task data */ if (hio_dev_sck_read(csck, !(thr_task->over & THR_TASK_OVER_READ_FROM_CLIENT)) <= -1) goto oops; - HIO_SVC_HTTS_TASKL_APPEND_TASK (&htts->task, thr_task); + HIO_SVC_HTTS_TASKL_APPEND_TASK (&htts->task, (hio_svc_htts_task_t*)thr_task); return 0; oops: diff --git a/lib/http-txt.c b/lib/http-txt.c index d5e083b..3a11124 100644 --- a/lib/http-txt.c +++ b/lib/http-txt.c @@ -390,7 +390,7 @@ int hio_svc_htts_dotxt (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r if (txt_send_final_status_to_client(txt, status_code, content_type, content_text, 0) <= -1) goto oops; - HIO_SVC_HTTS_TASKL_APPEND_TASK (&htts->task, txt); + HIO_SVC_HTTS_TASKL_APPEND_TASK (&htts->task, (hio_svc_htts_task_t*)txt); return 0; oops: diff --git a/lib/skad.c b/lib/skad.c index 5dc2c1e..4a944e8 100644 --- a/lib/skad.c +++ b/lib/skad.c @@ -1506,7 +1506,7 @@ void hio_skad_set_chan (hio_skad_t* _skad, hio_uint16_t chan) } } -hio_oow_t hio_skad_get_ipad_bytes (hio_skad_t* _skad, void* buf, hio_oow_t len) +hio_oow_t hio_skad_get_ipad_bytes (const hio_skad_t* _skad, void* buf, hio_oow_t len) { hio_skad_alt_t* skad = (hio_skad_alt_t*)_skad; hio_oow_t outlen = 0;