mirror of
https://github.com/lxsang/ant-http
synced 2024-12-26 00:38:21 +01:00
scheduler cause high CPU usage in syslog
This commit is contained in:
parent
883ef9c3a3
commit
e38cd9de1b
BIN
dist/antd-1.0.5b.tar.gz
vendored
BIN
dist/antd-1.0.5b.tar.gz
vendored
Binary file not shown.
585
lib/handle.c
585
lib/handle.c
@ -24,208 +24,270 @@
|
|||||||
|
|
||||||
#define HTML_TPL "<HTML><HEAD><TITLE>%s</TITLE></HEAD><BODY><h2>%s</h2></BODY></HTML>"
|
#define HTML_TPL "<HTML><HEAD><TITLE>%s</TITLE></HEAD><BODY><h2>%s</h2></BODY></HTML>"
|
||||||
|
|
||||||
static const char* S_100 = "Continue";
|
static const char *S_100 = "Continue";
|
||||||
static const char* S_101 = "Switching Protocols";
|
static const char *S_101 = "Switching Protocols";
|
||||||
static const char* S_102 = "Processing";
|
static const char *S_102 = "Processing";
|
||||||
static const char* S_103 = "Early Hints";
|
static const char *S_103 = "Early Hints";
|
||||||
|
|
||||||
static const char* S_200 = "OK";
|
static const char *S_200 = "OK";
|
||||||
static const char* S_201 = "Created";
|
static const char *S_201 = "Created";
|
||||||
static const char* S_202 = "Accepted";
|
static const char *S_202 = "Accepted";
|
||||||
static const char* S_203 = "Non-Authoritative Information";
|
static const char *S_203 = "Non-Authoritative Information";
|
||||||
static const char* S_204 = "No Content";
|
static const char *S_204 = "No Content";
|
||||||
static const char* S_205 = "Reset Content";
|
static const char *S_205 = "Reset Content";
|
||||||
static const char* S_206 = "Partial Content";
|
static const char *S_206 = "Partial Content";
|
||||||
static const char* S_207 = "Multi-Status";
|
static const char *S_207 = "Multi-Status";
|
||||||
static const char* S_208 = "Already Reported";
|
static const char *S_208 = "Already Reported";
|
||||||
static const char* S_226 = "IM Used";
|
static const char *S_226 = "IM Used";
|
||||||
|
|
||||||
static const char* S_300 = "Multiple Choices";
|
static const char *S_300 = "Multiple Choices";
|
||||||
static const char* S_301 = "Moved Permanently";
|
static const char *S_301 = "Moved Permanently";
|
||||||
static const char* S_302 = "Found";
|
static const char *S_302 = "Found";
|
||||||
static const char* S_303 = "See Other";
|
static const char *S_303 = "See Other";
|
||||||
static const char* S_304 = "Not Modified";
|
static const char *S_304 = "Not Modified";
|
||||||
static const char* S_305 = "Use Proxy";
|
static const char *S_305 = "Use Proxy";
|
||||||
static const char* S_306 = "Switch Proxy";
|
static const char *S_306 = "Switch Proxy";
|
||||||
static const char* S_307 = "Temporary Redirect";
|
static const char *S_307 = "Temporary Redirect";
|
||||||
static const char* S_308 = "Permanent Redirect";
|
static const char *S_308 = "Permanent Redirect";
|
||||||
|
|
||||||
static const char* S_400 = "Bad Request";
|
static const char *S_400 = "Bad Request";
|
||||||
static const char* S_401 = "Unauthorized";
|
static const char *S_401 = "Unauthorized";
|
||||||
static const char* S_402 = "Payment Required";
|
static const char *S_402 = "Payment Required";
|
||||||
static const char* S_403 = "Forbidden";
|
static const char *S_403 = "Forbidden";
|
||||||
static const char* S_404 = "Not Found";
|
static const char *S_404 = "Not Found";
|
||||||
static const char* S_405 = "Method Not Allowed";
|
static const char *S_405 = "Method Not Allowed";
|
||||||
static const char* S_406 = "Not Acceptable";
|
static const char *S_406 = "Not Acceptable";
|
||||||
static const char* S_407 = "Proxy Authentication Required";
|
static const char *S_407 = "Proxy Authentication Required";
|
||||||
static const char* S_408 = "Request Timeout";
|
static const char *S_408 = "Request Timeout";
|
||||||
static const char* S_409 = "Conflict";
|
static const char *S_409 = "Conflict";
|
||||||
static const char* S_410 = "Gone";
|
static const char *S_410 = "Gone";
|
||||||
static const char* S_411 = "Length Required";
|
static const char *S_411 = "Length Required";
|
||||||
static const char* S_412 = "Precondition Failed";
|
static const char *S_412 = "Precondition Failed";
|
||||||
static const char* S_413 = "Payload Too Large";
|
static const char *S_413 = "Payload Too Large";
|
||||||
static const char* S_414 = "URI Too Long";
|
static const char *S_414 = "URI Too Long";
|
||||||
static const char* S_415 = "Unsupported Media Type";
|
static const char *S_415 = "Unsupported Media Type";
|
||||||
static const char* S_416 = "Range Not Satisfiable";
|
static const char *S_416 = "Range Not Satisfiable";
|
||||||
static const char* S_417 = "Expectation Failed";
|
static const char *S_417 = "Expectation Failed";
|
||||||
static const char* S_421 = "Misdirected Request";
|
static const char *S_421 = "Misdirected Request";
|
||||||
static const char* S_422 = "Unprocessable Entity";
|
static const char *S_422 = "Unprocessable Entity";
|
||||||
static const char* S_423 = "Locked";
|
static const char *S_423 = "Locked";
|
||||||
static const char* S_424 = "Failed Dependency";
|
static const char *S_424 = "Failed Dependency";
|
||||||
static const char* S_425 = "Too Early";
|
static const char *S_425 = "Too Early";
|
||||||
static const char* S_426 = "Upgrade Required";
|
static const char *S_426 = "Upgrade Required";
|
||||||
static const char* S_428 = "Precondition Required";
|
static const char *S_428 = "Precondition Required";
|
||||||
static const char* S_429 = "Too Many Requests";
|
static const char *S_429 = "Too Many Requests";
|
||||||
static const char* S_431 = "Request Header Fields Too Large";
|
static const char *S_431 = "Request Header Fields Too Large";
|
||||||
static const char* S_451 = "Unavailable For Legal Reasons";
|
static const char *S_451 = "Unavailable For Legal Reasons";
|
||||||
|
|
||||||
static const char* S_500 = "Internal Server Error";
|
static const char *S_500 = "Internal Server Error";
|
||||||
static const char* S_501 = "Not Implemented";
|
static const char *S_501 = "Not Implemented";
|
||||||
static const char* S_502 = "Bad Gateway";
|
static const char *S_502 = "Bad Gateway";
|
||||||
static const char* S_503 = "Service Unavailable";
|
static const char *S_503 = "Service Unavailable";
|
||||||
static const char* S_504 = "Gateway Timeout";
|
static const char *S_504 = "Gateway Timeout";
|
||||||
static const char* S_505 = "HTTP Version Not Supported";
|
static const char *S_505 = "HTTP Version Not Supported";
|
||||||
static const char* S_506 = "Variant Also Negotiates";
|
static const char *S_506 = "Variant Also Negotiates";
|
||||||
static const char* S_507 = "Insufficient Storage";
|
static const char *S_507 = "Insufficient Storage";
|
||||||
static const char* S_508 = "Loop Detected";
|
static const char *S_508 = "Loop Detected";
|
||||||
static const char* S_510 = "Not Extended";
|
static const char *S_510 = "Not Extended";
|
||||||
static const char* S_511 = "Network Authentication Required";
|
static const char *S_511 = "Network Authentication Required";
|
||||||
static const char* S_UNOF = "Unofficial Status";
|
static const char *S_UNOF = "Unofficial Status";
|
||||||
|
|
||||||
|
int require_plugin(const char *name)
|
||||||
int require_plugin(const char* name)
|
|
||||||
{
|
{
|
||||||
UNUSED(name);
|
UNUSED(name);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int compressable(char* ctype)
|
int compressable(char *ctype)
|
||||||
{
|
{
|
||||||
UNUSED(ctype);
|
UNUSED(ctype);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void htdocs(antd_request_t* rq, char* dest)
|
void htdocs(antd_request_t *rq, char *dest)
|
||||||
{
|
{
|
||||||
dictionary_t xheader = (dictionary_t)dvalue(rq->request, "REQUEST_HEADER");
|
dictionary_t xheader = (dictionary_t)dvalue(rq->request, "REQUEST_HEADER");
|
||||||
char* www = (char*)dvalue(xheader, "SERVER_WWW_ROOT");
|
char *www = (char *)dvalue(xheader, "SERVER_WWW_ROOT");
|
||||||
if(www)
|
if (www)
|
||||||
{
|
{
|
||||||
strcpy(dest,www);
|
strcpy(dest, www);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void dbdir(char* dest)
|
void dbdir(char *dest)
|
||||||
{
|
{
|
||||||
UNUSED(dest);
|
UNUSED(dest);
|
||||||
}
|
}
|
||||||
void tmpdir(char* dest)
|
void tmpdir(char *dest)
|
||||||
{
|
{
|
||||||
UNUSED(dest);
|
UNUSED(dest);
|
||||||
}
|
}
|
||||||
void plugindir(char* dest)
|
void plugindir(char *dest)
|
||||||
{
|
{
|
||||||
UNUSED(dest);
|
UNUSED(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* get_status_str(int stat)
|
const char *get_status_str(int stat)
|
||||||
{
|
{
|
||||||
switch(stat)
|
switch (stat)
|
||||||
{
|
{
|
||||||
case 100: return S_100;
|
case 100:
|
||||||
case 101: return S_101;
|
return S_100;
|
||||||
case 102: return S_102;
|
case 101:
|
||||||
case 103: return S_103;
|
return S_101;
|
||||||
|
case 102:
|
||||||
|
return S_102;
|
||||||
|
case 103:
|
||||||
|
return S_103;
|
||||||
|
|
||||||
case 200: return S_200;
|
case 200:
|
||||||
case 201: return S_201;
|
return S_200;
|
||||||
case 202: return S_202;
|
case 201:
|
||||||
case 203: return S_203;
|
return S_201;
|
||||||
case 204: return S_204;
|
case 202:
|
||||||
case 205: return S_205;
|
return S_202;
|
||||||
case 206: return S_206;
|
case 203:
|
||||||
case 207: return S_207;
|
return S_203;
|
||||||
case 208: return S_208;
|
case 204:
|
||||||
case 226: return S_226;
|
return S_204;
|
||||||
|
case 205:
|
||||||
|
return S_205;
|
||||||
|
case 206:
|
||||||
|
return S_206;
|
||||||
|
case 207:
|
||||||
|
return S_207;
|
||||||
|
case 208:
|
||||||
|
return S_208;
|
||||||
|
case 226:
|
||||||
|
return S_226;
|
||||||
|
|
||||||
case 300: return S_300;
|
case 300:
|
||||||
case 301: return S_301;
|
return S_300;
|
||||||
case 302: return S_302;
|
case 301:
|
||||||
case 303: return S_303;
|
return S_301;
|
||||||
case 304: return S_304;
|
case 302:
|
||||||
case 305: return S_305;
|
return S_302;
|
||||||
case 306: return S_306;
|
case 303:
|
||||||
case 307: return S_307;
|
return S_303;
|
||||||
case 308: return S_308;
|
case 304:
|
||||||
|
return S_304;
|
||||||
|
case 305:
|
||||||
|
return S_305;
|
||||||
|
case 306:
|
||||||
|
return S_306;
|
||||||
|
case 307:
|
||||||
|
return S_307;
|
||||||
|
case 308:
|
||||||
|
return S_308;
|
||||||
|
|
||||||
case 400: return S_400;
|
case 400:
|
||||||
case 401: return S_401;
|
return S_400;
|
||||||
case 402: return S_402;
|
case 401:
|
||||||
case 403: return S_403;
|
return S_401;
|
||||||
case 404: return S_404;
|
case 402:
|
||||||
case 405: return S_405;
|
return S_402;
|
||||||
case 406: return S_406;
|
case 403:
|
||||||
case 407: return S_407;
|
return S_403;
|
||||||
case 408: return S_408;
|
case 404:
|
||||||
case 409: return S_409;
|
return S_404;
|
||||||
case 410: return S_410;
|
case 405:
|
||||||
case 411: return S_411;
|
return S_405;
|
||||||
case 412: return S_412;
|
case 406:
|
||||||
case 413: return S_413;
|
return S_406;
|
||||||
case 414: return S_414;
|
case 407:
|
||||||
case 415: return S_415;
|
return S_407;
|
||||||
case 416: return S_416;
|
case 408:
|
||||||
case 417: return S_417;
|
return S_408;
|
||||||
case 421: return S_421;
|
case 409:
|
||||||
case 422: return S_422;
|
return S_409;
|
||||||
case 423: return S_423;
|
case 410:
|
||||||
case 424: return S_424;
|
return S_410;
|
||||||
case 425: return S_425;
|
case 411:
|
||||||
case 426: return S_426;
|
return S_411;
|
||||||
case 428: return S_428;
|
case 412:
|
||||||
case 429: return S_429;
|
return S_412;
|
||||||
case 431: return S_431;
|
case 413:
|
||||||
case 451: return S_451;
|
return S_413;
|
||||||
|
case 414:
|
||||||
|
return S_414;
|
||||||
|
case 415:
|
||||||
|
return S_415;
|
||||||
|
case 416:
|
||||||
|
return S_416;
|
||||||
|
case 417:
|
||||||
|
return S_417;
|
||||||
|
case 421:
|
||||||
|
return S_421;
|
||||||
|
case 422:
|
||||||
|
return S_422;
|
||||||
|
case 423:
|
||||||
|
return S_423;
|
||||||
|
case 424:
|
||||||
|
return S_424;
|
||||||
|
case 425:
|
||||||
|
return S_425;
|
||||||
|
case 426:
|
||||||
|
return S_426;
|
||||||
|
case 428:
|
||||||
|
return S_428;
|
||||||
|
case 429:
|
||||||
|
return S_429;
|
||||||
|
case 431:
|
||||||
|
return S_431;
|
||||||
|
case 451:
|
||||||
|
return S_451;
|
||||||
|
|
||||||
case 500: return S_500;
|
case 500:
|
||||||
case 501: return S_501;
|
return S_500;
|
||||||
case 502: return S_502;
|
case 501:
|
||||||
case 503: return S_503;
|
return S_501;
|
||||||
case 504: return S_504;
|
case 502:
|
||||||
case 505: return S_505;
|
return S_502;
|
||||||
case 506: return S_506;
|
case 503:
|
||||||
case 507: return S_507;
|
return S_503;
|
||||||
case 508: return S_508;
|
case 504:
|
||||||
case 510: return S_510;
|
return S_504;
|
||||||
case 511: return S_511;
|
case 505:
|
||||||
default: return S_UNOF;
|
return S_505;
|
||||||
|
case 506:
|
||||||
|
return S_506;
|
||||||
|
case 507:
|
||||||
|
return S_507;
|
||||||
|
case 508:
|
||||||
|
return S_508;
|
||||||
|
case 510:
|
||||||
|
return S_510;
|
||||||
|
case 511:
|
||||||
|
return S_511;
|
||||||
|
default:
|
||||||
|
return S_UNOF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void antd_send_header(void* cl, antd_response_header_t* res)
|
void antd_send_header(void *cl, antd_response_header_t *res)
|
||||||
{
|
{
|
||||||
if(!res->header)
|
if (!res->header)
|
||||||
res->header = dict();
|
res->header = dict();
|
||||||
antd_client_t* client = (antd_client_t*) cl;
|
antd_client_t *client = (antd_client_t *)cl;
|
||||||
#ifdef USE_ZLIB
|
#ifdef USE_ZLIB
|
||||||
antd_compress_t current_zlevel = client->z_level;
|
antd_compress_t current_zlevel = client->z_level;
|
||||||
char* str = dvalue(res->header,"Content-Encoding");
|
char *str = dvalue(res->header, "Content-Encoding");
|
||||||
if(!str)
|
if (!str)
|
||||||
{
|
{
|
||||||
// check for compress
|
// check for compress
|
||||||
str = dvalue(res->header,"Content-Type");
|
str = dvalue(res->header, "Content-Type");
|
||||||
if(str)
|
if (str)
|
||||||
{
|
{
|
||||||
if(compressable(str) && client->z_level != ANTD_CNONE)
|
if (compressable(str) && client->z_level != ANTD_CNONE)
|
||||||
{
|
{
|
||||||
client->zstream = (z_stream *) malloc(sizeof(z_stream));
|
client->zstream = (z_stream *)malloc(sizeof(z_stream));
|
||||||
if(client->zstream)
|
if (client->zstream)
|
||||||
{
|
{
|
||||||
((z_stream*)client->zstream)->zalloc = Z_NULL;
|
((z_stream *)client->zstream)->zalloc = Z_NULL;
|
||||||
((z_stream*)client->zstream)->zfree = Z_NULL;
|
((z_stream *)client->zstream)->zfree = Z_NULL;
|
||||||
((z_stream*)client->zstream)->opaque = Z_NULL;
|
((z_stream *)client->zstream)->opaque = Z_NULL;
|
||||||
if(client->z_level == ANTD_CGZ)
|
if (client->z_level == ANTD_CGZ)
|
||||||
{
|
{
|
||||||
if(deflateInit2(client->zstream,Z_BEST_COMPRESSION,Z_DEFLATED,15 | 16, 8,Z_DEFAULT_STRATEGY) != Z_OK)
|
if (deflateInit2(client->zstream, Z_BEST_COMPRESSION, Z_DEFLATED, 15 | 16, 8, Z_DEFAULT_STRATEGY) != Z_OK)
|
||||||
{
|
{
|
||||||
ERROR("Cannot init gzip stream");
|
ERROR("Cannot init gzip stream");
|
||||||
free(client->zstream);
|
free(client->zstream);
|
||||||
@ -234,12 +296,12 @@ void antd_send_header(void* cl, antd_response_header_t* res)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->status = Z_NO_FLUSH;
|
client->status = Z_NO_FLUSH;
|
||||||
dput(res->header,"Content-Encoding", strdup("gzip"));
|
dput(res->header, "Content-Encoding", strdup("gzip"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(deflateInit(client->zstream, Z_BEST_COMPRESSION) != Z_OK)
|
if (deflateInit(client->zstream, Z_BEST_COMPRESSION) != Z_OK)
|
||||||
{
|
{
|
||||||
ERROR("Cannot init deflate stream");
|
ERROR("Cannot init deflate stream");
|
||||||
free(client->zstream);
|
free(client->zstream);
|
||||||
@ -248,7 +310,7 @@ void antd_send_header(void* cl, antd_response_header_t* res)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
client->status = Z_NO_FLUSH;
|
client->status = Z_NO_FLUSH;
|
||||||
dput(res->header,"Content-Encoding", strdup("deflate"));
|
dput(res->header, "Content-Encoding", strdup("deflate"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,29 +319,29 @@ void antd_send_header(void* cl, antd_response_header_t* res)
|
|||||||
}
|
}
|
||||||
client->z_level = ANTD_CNONE;
|
client->z_level = ANTD_CNONE;
|
||||||
#endif
|
#endif
|
||||||
dput(res->header,"Server", strdup(SERVER_NAME));
|
dput(res->header, "Server", strdup(SERVER_NAME));
|
||||||
const char* stat_str = get_status_str(res->status);
|
const char *stat_str = get_status_str(res->status);
|
||||||
__t(client, "HTTP/1.1 %d %s", res->status, stat_str);
|
__t(client, "HTTP/1.1 %d %s", res->status, stat_str);
|
||||||
chain_t it;
|
chain_t it;
|
||||||
for_each_assoc(it, res->header)
|
for_each_assoc(it, res->header)
|
||||||
{
|
{
|
||||||
__t(client,"%s: %s", it->key, (const char*)it->value);
|
__t(client, "%s: %s", it->key, (const char *)it->value);
|
||||||
}
|
}
|
||||||
// send out cookie
|
// send out cookie
|
||||||
if(res->cookie)
|
if (res->cookie)
|
||||||
{
|
{
|
||||||
item_t el;
|
item_t el;
|
||||||
list_for_each(el, res->cookie)
|
list_for_each(el, res->cookie)
|
||||||
{
|
{
|
||||||
if(el->type == LIST_TYPE_POINTER && el->value.ptr)
|
if (el->type == LIST_TYPE_POINTER && el->value.ptr)
|
||||||
{
|
{
|
||||||
__t(client,"Set-Cookie: %s", (char*)el->value.ptr);
|
__t(client, "Set-Cookie: %s", (char *)el->value.ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list_free(&res->cookie);
|
list_free(&res->cookie);
|
||||||
res->cookie = NULL;
|
res->cookie = NULL;
|
||||||
}
|
}
|
||||||
__b(client, (unsigned char*)"\r\n", 2);
|
__b(client, (unsigned char *)"\r\n", 2);
|
||||||
#ifdef USE_ZLIB
|
#ifdef USE_ZLIB
|
||||||
client->z_level = current_zlevel;
|
client->z_level = current_zlevel;
|
||||||
#endif
|
#endif
|
||||||
@ -297,24 +359,23 @@ void octstream(void* client, char* name)
|
|||||||
//Content-Disposition: attachment; filename="fname.ext"
|
//Content-Disposition: attachment; filename="fname.ext"
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
int antd_send(void *src, const void *data_in, int len_in)
|
||||||
int antd_send(void *src, const void* data_in, int len_in)
|
|
||||||
{
|
{
|
||||||
uint8_t* data = (uint8_t*)data_in;
|
uint8_t *data = (uint8_t *)data_in;
|
||||||
int len = len_in;
|
int len = len_in;
|
||||||
antd_client_t * source = (antd_client_t *) src;
|
antd_client_t *source = (antd_client_t *)src;
|
||||||
if(!src || !data)
|
if (!src || !data)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_ZLIB
|
#ifdef USE_ZLIB
|
||||||
if(source->zstream && source->z_level != ANTD_CNONE)
|
if (source->zstream && source->z_level != ANTD_CNONE)
|
||||||
{
|
{
|
||||||
antd_compress_t current_zlevel = source->z_level;
|
antd_compress_t current_zlevel = source->z_level;
|
||||||
source->z_level = ANTD_CNONE;
|
source->z_level = ANTD_CNONE;
|
||||||
uint8_t buf[BUFFLEN];
|
uint8_t buf[BUFFLEN];
|
||||||
z_stream* zstream = (z_stream*) source->zstream;
|
z_stream *zstream = (z_stream *)source->zstream;
|
||||||
zstream->avail_in = (uInt)len;
|
zstream->avail_in = (uInt)len;
|
||||||
zstream->next_in = (Bytef *)data_in;
|
zstream->next_in = (Bytef *)data_in;
|
||||||
len = 0;
|
len = 0;
|
||||||
@ -323,7 +384,7 @@ int antd_send(void *src, const void* data_in, int len_in)
|
|||||||
{
|
{
|
||||||
zstream->avail_out = BUFFLEN;
|
zstream->avail_out = BUFFLEN;
|
||||||
zstream->next_out = buf;
|
zstream->next_out = buf;
|
||||||
if(deflate(zstream, source->status) == Z_STREAM_ERROR)
|
if (deflate(zstream, source->status) == Z_STREAM_ERROR)
|
||||||
{
|
{
|
||||||
source->z_level = current_zlevel;
|
source->z_level = current_zlevel;
|
||||||
data = NULL;
|
data = NULL;
|
||||||
@ -335,24 +396,24 @@ int antd_send(void *src, const void* data_in, int len_in)
|
|||||||
antd_send(source, buf, have);
|
antd_send(source, buf, have);
|
||||||
len += have;
|
len += have;
|
||||||
}
|
}
|
||||||
} while(zstream->avail_out == 0);
|
} while (zstream->avail_out == 0);
|
||||||
source->z_level = current_zlevel;
|
source->z_level = current_zlevel;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int written;
|
int written;
|
||||||
char* ptr;
|
char *ptr;
|
||||||
int writelen = 0;
|
int writelen = 0;
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
#ifdef USE_OPENSSL
|
#ifdef USE_OPENSSL
|
||||||
if(source->ssl)
|
if (source->ssl)
|
||||||
{
|
{
|
||||||
//LOG("SSL WRITE\n");
|
//LOG("SSL WRITE\n");
|
||||||
//ret = SSL_write((SSL*) source->ssl, data, len);
|
//ret = SSL_write((SSL*) source->ssl, data, len);
|
||||||
ptr = (char* )data;
|
ptr = (char *)data;
|
||||||
writelen = len > BUFFLEN?BUFFLEN:len;
|
writelen = len > BUFFLEN ? BUFFLEN : len;
|
||||||
written = 0;
|
written = 0;
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
@ -360,19 +421,19 @@ int antd_send(void *src, const void* data_in, int len_in)
|
|||||||
{
|
{
|
||||||
// clear the error queue
|
// clear the error queue
|
||||||
ERR_clear_error();
|
ERR_clear_error();
|
||||||
count = SSL_write (source->ssl, ptr+written, writelen);
|
count = SSL_write(source->ssl, ptr + written, writelen);
|
||||||
int err = SSL_get_error(source->ssl, count);
|
int err = SSL_get_error(source->ssl, count);
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
written += count;
|
written += count;
|
||||||
writelen = (len - written) > BUFFLEN?BUFFLEN:(len-written);
|
writelen = (len - written) > BUFFLEN ? BUFFLEN : (len - written);
|
||||||
time(&source->last_io);
|
time(&source->last_io);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(difftime( time(NULL), source->last_io) > MAX_IO_WAIT_TIME)
|
if (difftime(time(NULL), source->last_io) > MAX_IO_WAIT_TIME)
|
||||||
{
|
{
|
||||||
if(written == 0)
|
if (written == 0)
|
||||||
written = count;
|
written = count;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -405,7 +466,7 @@ int antd_send(void *src, const void* data_in, int len_in)
|
|||||||
|
|
||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
timeout.tv_usec = 500;
|
timeout.tv_usec = 500;
|
||||||
err = select(sock+1, &fds, NULL, NULL, &timeout);
|
err = select(sock + 1, &fds, NULL, NULL, &timeout);
|
||||||
if (err == 0 || (err > 0 && FD_ISSET(sock, &fds)))
|
if (err == 0 || (err > 0 && FD_ISSET(sock, &fds)))
|
||||||
{
|
{
|
||||||
//source->attempt++;
|
//source->attempt++;
|
||||||
@ -426,7 +487,7 @@ int antd_send(void *src, const void* data_in, int len_in)
|
|||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
timeout.tv_usec = 500;
|
timeout.tv_usec = 500;
|
||||||
|
|
||||||
err = select(sock+1, NULL, &fds, NULL, &timeout);
|
err = select(sock + 1, NULL, &fds, NULL, &timeout);
|
||||||
if (err == 0 || (err > 0 && FD_ISSET(sock, &fds)))
|
if (err == 0 || (err > 0 && FD_ISSET(sock, &fds)))
|
||||||
{
|
{
|
||||||
//source->attempt++;
|
//source->attempt++;
|
||||||
@ -443,7 +504,7 @@ int antd_send(void *src, const void* data_in, int len_in)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(written == 0)
|
if (written == 0)
|
||||||
written = count;
|
written = count;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -453,21 +514,21 @@ int antd_send(void *src, const void* data_in, int len_in)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
ptr = (char* )data;
|
ptr = (char *)data;
|
||||||
writelen = len > BUFFLEN?BUFFLEN:len;
|
writelen = len > BUFFLEN ? BUFFLEN : len;
|
||||||
written = 0;
|
written = 0;
|
||||||
while (writelen > 0)
|
while (writelen > 0)
|
||||||
{
|
{
|
||||||
count = send(source->sock, ptr+written, writelen, 0);
|
count = send(source->sock, ptr + written, writelen, 0);
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
written += count;
|
written += count;
|
||||||
writelen = (len - written) > BUFFLEN?BUFFLEN:(len-written);
|
writelen = (len - written) > BUFFLEN ? BUFFLEN : (len - written);
|
||||||
time(&source->last_io);
|
time(&source->last_io);
|
||||||
}
|
}
|
||||||
else if(difftime( time(NULL), source->last_io) > MAX_IO_WAIT_TIME || (count == -1 && errno != EAGAIN && errno != EWOULDBLOCK))
|
else if (difftime(time(NULL), source->last_io) > MAX_IO_WAIT_TIME || (count == -1 && errno != EAGAIN && errno != EWOULDBLOCK))
|
||||||
{
|
{
|
||||||
if(written == 0)
|
if (written == 0)
|
||||||
written = count;
|
written = count;
|
||||||
//ERROR("Error while writing: %s", strerror(errno));
|
//ERROR("Error while writing: %s", strerror(errno));
|
||||||
break;
|
break;
|
||||||
@ -480,39 +541,40 @@ int antd_send(void *src, const void* data_in, int len_in)
|
|||||||
|
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
int antd_recv(void *src, void* data, int len)
|
int antd_recv(void *src, void *data, int len)
|
||||||
{
|
{
|
||||||
if(!src) return -1;
|
if (!src)
|
||||||
int read=0;
|
return -1;
|
||||||
char* ptr = NULL;
|
int read = 0;
|
||||||
int received=0;
|
char *ptr = NULL;
|
||||||
int readlen=0;
|
int received = 0;
|
||||||
antd_client_t * source = (antd_client_t *) src;
|
int readlen = 0;
|
||||||
|
antd_client_t *source = (antd_client_t *)src;
|
||||||
#ifdef USE_OPENSSL
|
#ifdef USE_OPENSSL
|
||||||
if(source->ssl)
|
if (source->ssl)
|
||||||
{
|
{
|
||||||
ptr = (char* )data;
|
ptr = (char *)data;
|
||||||
readlen = len > BUFFLEN?BUFFLEN:len;
|
readlen = len > BUFFLEN ? BUFFLEN : len;
|
||||||
read = 0;
|
read = 0;
|
||||||
fd_set fds;
|
fd_set fds;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
while (readlen > 0 )//&& source->attempt < MAX_ATTEMPT
|
while (readlen > 0) //&& source->attempt < MAX_ATTEMPT
|
||||||
{
|
{
|
||||||
ERR_clear_error();
|
ERR_clear_error();
|
||||||
received = SSL_read (source->ssl, ptr+read, readlen);
|
received = SSL_read(source->ssl, ptr + read, readlen);
|
||||||
int err = SSL_get_error(source->ssl, received);
|
int err = SSL_get_error(source->ssl, received);
|
||||||
if (received > 0)
|
if (received > 0)
|
||||||
{
|
{
|
||||||
read += received;
|
read += received;
|
||||||
readlen = (len - read) > BUFFLEN?BUFFLEN:(len-read);
|
readlen = (len - read) > BUFFLEN ? BUFFLEN : (len - read);
|
||||||
time(&source->last_io);
|
time(&source->last_io);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Timeout, quit
|
// Timeout, quit
|
||||||
if(difftime( time(NULL), source->last_io) > MAX_IO_WAIT_TIME)
|
if (difftime(time(NULL), source->last_io) > MAX_IO_WAIT_TIME)
|
||||||
{
|
{
|
||||||
if(read == 0)
|
if (read == 0)
|
||||||
read = received;
|
read = received;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -545,7 +607,7 @@ int antd_recv(void *src, void* data, int len)
|
|||||||
|
|
||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
timeout.tv_usec = 500;
|
timeout.tv_usec = 500;
|
||||||
err = select(sock+1, &fds, NULL, NULL, &timeout);
|
err = select(sock + 1, &fds, NULL, NULL, &timeout);
|
||||||
if (err == 0 || (err > 0 && FD_ISSET(sock, &fds)))
|
if (err == 0 || (err > 0 && FD_ISSET(sock, &fds)))
|
||||||
{
|
{
|
||||||
//source->attempt++;
|
//source->attempt++;
|
||||||
@ -566,7 +628,7 @@ int antd_recv(void *src, void* data, int len)
|
|||||||
timeout.tv_sec = 0;
|
timeout.tv_sec = 0;
|
||||||
timeout.tv_usec = 500;
|
timeout.tv_usec = 500;
|
||||||
|
|
||||||
err = select(sock+1, NULL, &fds, NULL, &timeout);
|
err = select(sock + 1, NULL, &fds, NULL, &timeout);
|
||||||
if (err == 0 || (err > 0 && FD_ISSET(sock, &fds)))
|
if (err == 0 || (err > 0 && FD_ISSET(sock, &fds)))
|
||||||
{
|
{
|
||||||
//source->attempt++;
|
//source->attempt++;
|
||||||
@ -583,7 +645,7 @@ int antd_recv(void *src, void* data, int len)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(read == 0)
|
if (read == 0)
|
||||||
read = received;
|
read = received;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -611,24 +673,24 @@ int antd_recv(void *src, void* data, int len)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
ptr = (char* )data;
|
ptr = (char *)data;
|
||||||
readlen = len > BUFFLEN?BUFFLEN:len;
|
readlen = len > BUFFLEN ? BUFFLEN : len;
|
||||||
read = 0;
|
read = 0;
|
||||||
while (readlen > 0 )
|
while (readlen > 0)
|
||||||
{
|
{
|
||||||
received = recv(((int) source->sock), ptr+read, readlen, 0);
|
received = recv(((int)source->sock), ptr + read, readlen, 0);
|
||||||
//LOG("Read : %c\n", *ptr);
|
//LOG("Read : %c\n", *ptr);
|
||||||
if (received > 0)
|
if (received > 0)
|
||||||
{
|
{
|
||||||
read += received;
|
read += received;
|
||||||
readlen = (len - read) > BUFFLEN?BUFFLEN:(len-read);
|
readlen = (len - read) > BUFFLEN ? BUFFLEN : (len - read);
|
||||||
time(&source->last_io);
|
time(&source->last_io);
|
||||||
//LOG("Read len is %d\n", readlen);
|
//LOG("Read len is %d\n", readlen);
|
||||||
}
|
}
|
||||||
else if( difftime( time(NULL), source->last_io) > MAX_IO_WAIT_TIME || (errno != EAGAIN && errno != EWOULDBLOCK))
|
else if (difftime(time(NULL), source->last_io) > MAX_IO_WAIT_TIME || (errno != EAGAIN && errno != EWOULDBLOCK))
|
||||||
{
|
{
|
||||||
//ERROR("Error while reading: %s", strerror(errno));
|
//ERROR("Error while reading: %s", strerror(errno));
|
||||||
if(read ==0)
|
if (read == 0)
|
||||||
read = received;
|
read = received;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -644,9 +706,10 @@ int antd_recv(void *src, void* data, int len)
|
|||||||
}*/
|
}*/
|
||||||
return read;
|
return read;
|
||||||
}
|
}
|
||||||
void set_nonblock(int socket) {
|
void set_nonblock(int socket)
|
||||||
|
{
|
||||||
int flags;
|
int flags;
|
||||||
flags = fcntl(socket,F_GETFL,0);
|
flags = fcntl(socket, F_GETFL, 0);
|
||||||
//assert(flags != -1);
|
//assert(flags != -1);
|
||||||
fcntl(socket, F_SETFL, flags | O_NONBLOCK);
|
fcntl(socket, F_SETFL, flags | O_NONBLOCK);
|
||||||
}
|
}
|
||||||
@ -657,15 +720,16 @@ void set_nonblock(int socket) {
|
|||||||
//assert(flags != -1);
|
//assert(flags != -1);
|
||||||
fcntl(socket, F_SETFL, flags & (~O_NONBLOCK));
|
fcntl(socket, F_SETFL, flags & (~O_NONBLOCK));
|
||||||
}*/
|
}*/
|
||||||
int antd_close(void* src)
|
int antd_close(void *src)
|
||||||
{
|
{
|
||||||
if(!src) return -1;
|
if (!src)
|
||||||
antd_client_t * source = (antd_client_t *) src;
|
return -1;
|
||||||
|
antd_client_t *source = (antd_client_t *)src;
|
||||||
#ifdef USE_ZLIB
|
#ifdef USE_ZLIB
|
||||||
//TODO: send finish data to the socket before quit
|
//TODO: send finish data to the socket before quit
|
||||||
if(source->zstream)
|
if (source->zstream)
|
||||||
{
|
{
|
||||||
if(source->status == Z_NO_FLUSH && source->z_level != ANTD_CNONE)
|
if (source->status == Z_NO_FLUSH && source->z_level != ANTD_CNONE)
|
||||||
{
|
{
|
||||||
source->status = Z_FINISH;
|
source->status = Z_FINISH;
|
||||||
antd_send(source, "", 0);
|
antd_send(source, "", 0);
|
||||||
@ -677,12 +741,13 @@ int antd_close(void* src)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_OPENSSL
|
#ifdef USE_OPENSSL
|
||||||
if(source->ssl){
|
if (source->ssl)
|
||||||
|
{
|
||||||
//printf("SSL:Shutdown ssl\n");
|
//printf("SSL:Shutdown ssl\n");
|
||||||
//SSL_shutdown((SSL*) source->ssl);
|
//SSL_shutdown((SSL*) source->ssl);
|
||||||
SSL_set_shutdown((SSL*) source->ssl, SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
|
SSL_set_shutdown((SSL *)source->ssl, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);
|
||||||
//printf("SSL:Free ssl\n");
|
//printf("SSL:Free ssl\n");
|
||||||
SSL_free((SSL*) source->ssl);
|
SSL_free((SSL *)source->ssl);
|
||||||
|
|
||||||
//EVP_cleanup();
|
//EVP_cleanup();
|
||||||
//ENGINE_cleanup();
|
//ENGINE_cleanup();
|
||||||
@ -700,35 +765,35 @@ int antd_close(void* src)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int __t(void* client, const char* fstring,...)
|
int __t(void *client, const char *fstring, ...)
|
||||||
{
|
{
|
||||||
int dlen;
|
int dlen;
|
||||||
int st;
|
int st;
|
||||||
va_list arguments;
|
va_list arguments;
|
||||||
char * data;
|
char *data;
|
||||||
va_start( arguments, fstring);
|
va_start(arguments, fstring);
|
||||||
dlen = vsnprintf(0,0,fstring,arguments)+1;
|
dlen = vsnprintf(0, 0, fstring, arguments) + 1;
|
||||||
va_end(arguments);
|
va_end(arguments);
|
||||||
if ((data = (char*)malloc(dlen*sizeof(char))) != 0)
|
if ((data = (char *)malloc(dlen * sizeof(char))) != 0)
|
||||||
{
|
{
|
||||||
va_start(arguments, fstring);
|
va_start(arguments, fstring);
|
||||||
vsnprintf(data, dlen, fstring, arguments);
|
vsnprintf(data, dlen, fstring, arguments);
|
||||||
va_end(arguments);
|
va_end(arguments);
|
||||||
st = __b(client, (const unsigned char*)data, strlen(data));
|
st = __b(client, (const unsigned char *)data, strlen(data));
|
||||||
if(st)
|
if (st)
|
||||||
__b(client, (unsigned char*)"\r\n", 2);
|
__b(client, (unsigned char *)"\r\n", 2);
|
||||||
free(data);
|
free(data);
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
int __b(void* client, const unsigned char* data, int size)
|
int __b(void *client, const unsigned char *data, int size)
|
||||||
{
|
{
|
||||||
int sent = 0;
|
int sent = 0;
|
||||||
int buflen = 0;
|
int buflen = 0;
|
||||||
int nbytes = 0;
|
int nbytes = 0;
|
||||||
char* ptr = (char*)data;
|
char *ptr = (char *)data;
|
||||||
/*if(size <= BUFFLEN)
|
/*if(size <= BUFFLEN)
|
||||||
{
|
{
|
||||||
nbytes = antd_send(client,data,size);
|
nbytes = antd_send(client,data,size);
|
||||||
@ -736,14 +801,14 @@ int __b(void* client, const unsigned char* data, int size)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{*/
|
{*/
|
||||||
while(sent < size)
|
while (sent < size)
|
||||||
{
|
{
|
||||||
if(size - sent > BUFFLEN)
|
if (size - sent > BUFFLEN)
|
||||||
buflen = BUFFLEN;
|
buflen = BUFFLEN;
|
||||||
else
|
else
|
||||||
buflen = size - sent;
|
buflen = size - sent;
|
||||||
nbytes = antd_send(client,ptr,buflen);
|
nbytes = antd_send(client, ptr, buflen);
|
||||||
if(nbytes == -1)
|
if (nbytes == -1)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -753,27 +818,28 @@ int __b(void* client, const unsigned char* data, int size)
|
|||||||
//}
|
//}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int __f(void* client, const char* file)
|
int __f(void *client, const char *file)
|
||||||
{
|
{
|
||||||
unsigned char buffer[BUFFLEN];
|
unsigned char buffer[BUFFLEN];
|
||||||
FILE *ptr;
|
FILE *ptr;
|
||||||
ptr = fopen(file,"rb");
|
ptr = fopen(file, "rb");
|
||||||
if(!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
LOG("Cannot read : %s", file);
|
LOG("Cannot read : %s", file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
size_t size;
|
size_t size;
|
||||||
while(!feof(ptr))
|
while (!feof(ptr))
|
||||||
{
|
{
|
||||||
size = fread(buffer,1,BUFFLEN,ptr);
|
size = fread(buffer, 1, BUFFLEN, ptr);
|
||||||
if(antd_send(client,buffer,size) == -1) return 0;
|
if (antd_send(client, buffer, size) == -1)
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
fclose(ptr);
|
fclose(ptr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int upload(const char* tmp, const char* path)
|
int upload(const char *tmp, const char *path)
|
||||||
{
|
{
|
||||||
return !rename(tmp, path);
|
return !rename(tmp, path);
|
||||||
}
|
}
|
||||||
@ -801,43 +867,44 @@ void clear_cookie(void* client, dictionary_t dic)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void antd_error(void* client, int status, const char* msg)
|
void antd_error(void *client, int status, const char *msg)
|
||||||
{
|
{
|
||||||
antd_response_header_t rsh;
|
antd_response_header_t rsh;
|
||||||
rsh.header = dict();
|
rsh.header = dict();
|
||||||
rsh.cookie = NULL;
|
rsh.cookie = NULL;
|
||||||
const char* stat_str = get_status_str(status);
|
const char *stat_str = get_status_str(status);
|
||||||
rsh.status = status;
|
rsh.status = status;
|
||||||
char* ctype = "text/html; charset=utf-8";
|
char *ctype = "text/html; charset=utf-8";
|
||||||
dput(rsh.header, "Content-Type", strdup(ctype));
|
dput(rsh.header, "Content-Type", strdup(ctype));
|
||||||
char * res_str = __s(HTML_TPL, stat_str, msg);
|
char *res_str = __s(HTML_TPL, stat_str, msg);
|
||||||
int clen = 0;
|
int clen = 0;
|
||||||
if(res_str)
|
if (res_str)
|
||||||
{
|
{
|
||||||
clen = strlen(res_str);
|
clen = strlen(res_str);
|
||||||
}
|
}
|
||||||
char ibuf[20];
|
char ibuf[20];
|
||||||
snprintf (ibuf, sizeof(ibuf), "%d",clen);
|
snprintf(ibuf, sizeof(ibuf), "%d", clen);
|
||||||
#ifdef USE_ZLIB
|
#ifdef USE_ZLIB
|
||||||
if(((antd_client_t*)client)->z_level == ANTD_CNONE || !compressable(ctype))
|
if (((antd_client_t *)client)->z_level == ANTD_CNONE || !compressable(ctype))
|
||||||
#endif
|
#endif
|
||||||
dput(rsh.header, "Content-Length", strdup(ibuf));
|
dput(rsh.header, "Content-Length", strdup(ibuf));
|
||||||
antd_send_header(client, &rsh);
|
antd_send_header(client, &rsh);
|
||||||
if(res_str)
|
if (res_str)
|
||||||
{
|
{
|
||||||
//printf("%s\n", res_str);
|
//printf("%s\n", res_str);
|
||||||
__b(client, (unsigned char*)res_str, clen);
|
__b(client, (unsigned char *)res_str, clen);
|
||||||
//__t(client, HTML_TPL, stat_str, msg);
|
//__t(client, HTML_TPL, stat_str, msg);
|
||||||
free(res_str);
|
free(res_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ws_enable(dictionary_t dic)
|
int ws_enable(dictionary_t dic)
|
||||||
{
|
{
|
||||||
if(!dic) return 0;
|
if (!dic)
|
||||||
char*v = (char*)dvalue(dic, "__web_socket__");
|
return 0;
|
||||||
if(!v) return 0;
|
char *v = (char *)dvalue(dic, "__web_socket__");
|
||||||
|
if (!v)
|
||||||
|
return 0;
|
||||||
return atoi(v) == 1;
|
return atoi(v) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -850,7 +917,7 @@ int ws_enable(dictionary_t dic)
|
|||||||
* @param size size of buffer
|
* @param size size of buffer
|
||||||
* @return number of bytes read
|
* @return number of bytes read
|
||||||
*/
|
*/
|
||||||
int read_buf(void* sock, char*buf,int size)
|
int read_buf(void *sock, char *buf, int size)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char c = '\0';
|
char c = '\0';
|
||||||
|
@ -269,7 +269,6 @@ void antd_execute_task(antd_scheduler_t* scheduler, antd_task_item_t taski)
|
|||||||
if(!taski)
|
if(!taski)
|
||||||
return;
|
return;
|
||||||
// execute the task
|
// execute the task
|
||||||
LOG("Execute task with priority: %d", taski->task->priority);
|
|
||||||
void *ret = (*(taski->task->handle))(taski->task->data);
|
void *ret = (*(taski->task->handle))(taski->task->data);
|
||||||
// check the return data if it is a new task
|
// check the return data if it is a new task
|
||||||
if(!ret)
|
if(!ret)
|
||||||
|
Loading…
Reference in New Issue
Block a user