Merge branch 'master' into 3.3.0-releng

This commit is contained in:
Joris Vink 2019-05-31 09:15:24 +02:00
commit ea9fad0970
6 changed files with 52 additions and 16 deletions

View File

@ -91,6 +91,8 @@ void kore_curl_bind_request(struct kore_curl *, struct http_request *);
void kore_curl_bind_callback(struct kore_curl *,
void (*cb)(struct kore_curl *, void *), void *);
const char *kore_curl_strerror(struct kore_curl *);
#if defined(__cplusplus)
}
#endif

View File

@ -244,11 +244,24 @@ kore_curl_success(struct kore_curl *client)
return (client->result == CURLE_OK);
}
const char *
kore_curl_strerror(struct kore_curl *client)
{
const char *err;
if (client->errbuf[0] != '\0')
err = &client->errbuf[0];
else
err = curl_easy_strerror(client->result);
return (err);
}
void
kore_curl_logerror(struct kore_curl *client)
{
kore_log(LOG_NOTICE, "curl error: %s -> %s",
client->url, client->errbuf);
kore_log(LOG_NOTICE, "curl error: %s -> %s", client->url,
kore_curl_strerror(client));
}
void

View File

@ -313,6 +313,9 @@ http_process(void)
http_process_request(req);
total += req->ms;
if (req->flags & HTTP_REQUEST_DELETE)
http_request_free(req);
}
}

View File

@ -398,9 +398,10 @@ kore_server_bind_unix(const char *path, const char *ccb)
#if defined(__linux__)
if (sun.sun_path[0] == '@')
sun.sun_path[0] = '\0';
#endif
socklen = sizeof(sun.sun_family) + len;
#else
socklen = sizeof(sun);
#endif
if ((l = kore_listener_alloc(AF_UNIX, ccb)) == NULL)
return (KORE_RESULT_ERROR);

View File

@ -669,11 +669,11 @@ python_runtime_http_request(void *addr, struct http_request *req)
if (PyCoro_CheckExact(pyret)) {
req->py_coro = python_coro_create(pyret, req);
if (python_coro_run(req->py_coro) == KORE_RESULT_OK) {
http_request_wakeup(req);
kore_python_coro_delete(req->py_coro);
req->py_coro = NULL;
return (KORE_RESULT_OK);
}
http_request_sleep(req);
return (KORE_RESULT_RETRY);
}
@ -744,12 +744,12 @@ python_runtime_validator(void *addr, struct http_request *req, const void *data)
coro = python_coro_create(pyret, req);
req->py_coro = coro;
if (python_coro_run(coro) == KORE_RESULT_OK) {
http_request_wakeup(req);
ret = python_validator_check(coro->result);
kore_python_coro_delete(coro);
req->py_coro = NULL;
return (ret);
}
http_request_sleep(req);
return (KORE_RESULT_RETRY);
}
@ -1675,6 +1675,8 @@ pytimer_run(void *arg, u_int64_t now)
ret = PyObject_CallObject(timer->callable, NULL);
Py_XDECREF(ret);
kore_python_log_error("pytimer_run");
if (timer->flags & KORE_TIMER_ONESHOT) {
timer->run = NULL;
Py_DECREF((PyObject *)timer);
@ -2680,6 +2682,7 @@ pylock_do_release(struct pylock *lock)
if (op->locking == 0)
continue;
op->active = 0;
TAILQ_REMOVE(&op->lock->ops, op, list);
if (op->coro->request != NULL)
@ -2687,7 +2690,6 @@ pylock_do_release(struct pylock *lock)
else
python_coro_wakeup(op->coro);
op->active = 0;
Py_DECREF((PyObject *)op);
break;
}
@ -2731,14 +2733,27 @@ pylock_op_iternext(struct pylock_op *op)
pylock_do_release(op->lock);
} else {
if (op->lock->owner != NULL) {
/*
* We could be beat by another coroutine that grabbed
* the lock even if we were the one woken up for it.
*/
if (op->active == 0) {
op->active = 1;
TAILQ_INSERT_HEAD(&op->lock->ops, op, list);
Py_INCREF((PyObject *)op);
}
Py_RETURN_NONE;
}
op->lock->owner = coro_running;
}
op->active = 0;
TAILQ_REMOVE(&op->lock->ops, op, list);
if (op->active) {
op->active = 0;
TAILQ_REMOVE(&op->lock->ops, op, list);
Py_DECREF((PyObject *)op);
}
PyErr_SetNone(PyExc_StopIteration);
return (NULL);
@ -4238,13 +4253,11 @@ pyhttp_client_request(struct pyhttp_client *client, int m, PyObject *kwargs)
client->tlscert);
curl_easy_setopt(op->curl.handle, CURLOPT_SSLKEY,
client->tlskey);
}
if (client->tlsverify == 0) {
curl_easy_setopt(op->curl.handle,
CURLOPT_SSL_VERIFYHOST, 0);
curl_easy_setopt(op->curl.handle,
CURLOPT_SSL_VERIFYPEER, 0);
}
if (client->tlsverify == 0) {
curl_easy_setopt(op->curl.handle, CURLOPT_SSL_VERIFYHOST, 0);
curl_easy_setopt(op->curl.handle, CURLOPT_SSL_VERIFYPEER, 0);
}
if (client->cabundle != NULL) {
@ -4316,7 +4329,7 @@ pyhttp_client_op_iternext(struct pyhttp_client_op *op)
if (!kore_curl_success(&op->curl)) {
PyErr_Format(PyExc_RuntimeError, "request to '%s' failed: %s",
op->curl.url, op->curl.errbuf);
op->curl.url, kore_curl_strerror(&op->curl));
return (NULL);
}

View File

@ -428,6 +428,10 @@ kore_worker_entry(struct kore_worker *kw)
}
netwait = kore_timer_next_run(now);
if (netwait == KORE_WAIT_INFINITE && http_request_count > 0)
netwait = 100;
kore_platform_event_wait(netwait);
now = kore_time_ms();