[sheepdog] [PATCH v3] http: add http transport
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Thu Jul 4 09:10:56 CEST 2013
At Wed, 3 Jul 2013 17:34:39 +0800,
Liu Yuan wrote:
>
> +
> +static void http_handle_get(struct http_request *req)
> +{
> + http_response_header(req, OK);
> + http_request_writes(req, "not implemented\n");
> +}
I think 501 is usually used for the "not implemented" error.
> +int http_init(const char *address)
> +{
> + pthread_t t;
> + int err;
> +
> + if (!address)
> + return 0;
I think this NULL check should be done out of this function. If the
'-r' option is not specified, we don't need to call http_init().
> +
> + sys->http_wqueue = create_work_queue("http", WQ_DYNAMIC);
> + if (!sys->http_wqueue)
> + return -1;
> +
> + FCGX_Init();
> +
> +#define LISTEN_QUEUE_DEPTH 1024 /* No rationale */
> + http_sockfd = FCGX_OpenSocket(address, LISTEN_QUEUE_DEPTH);
> + if (http_sockfd < 0) {
> + sd_eprintf("open socket failed, address %s", address);
> + return -1;
> + }
> + sd_iprintf("http service listen at %s", address);
> + err = pthread_create(&t, NULL, http_main_loop, NULL);
> + if (err) {
> + sd_eprintf("%s", strerror(err));
> + return -1;
> + }
> + return 0;
> +}
> +/* http.c */
> +#ifdef HAVE_HTTP
> +int http_init(const char *address);
> +#else
> +static inline int http_init(const char *address)
> +{
> + if (address)
Then we can remove this if condition.
> + sd_iprintf("http service is not complied");
This is basically what the user doesn't expect, so I suggest printing
this message with higher priority (e.g. SDOG_NOTICE or SDOG_WARNING).
Thanks,
Kazutaka
More information about the sheepdog
mailing list