mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-27 15:01:03 +08:00
Fix #1505: let mg_wakeup() return status
This commit is contained in:
parent
a65c3288d8
commit
4474ada291
@ -657,7 +657,7 @@ Usage example: see [examples/multi-threaded](https://github.com/cesanta/mongoose
|
|||||||
### mg\_mgr\_wakeup()
|
### mg\_mgr\_wakeup()
|
||||||
|
|
||||||
```c
|
```c
|
||||||
void mg_mgr_wakeup(struct mg_connection *pipe, const void *buf, size_len len);
|
bool mg_mgr_wakeup(struct mg_connection *pipe, const void *buf, size_len len);
|
||||||
```
|
```
|
||||||
|
|
||||||
Wake up an event manager that sleeps in `mg_mgr_poll()` call. This function
|
Wake up an event manager that sleeps in `mg_mgr_poll()` call. This function
|
||||||
@ -673,7 +673,7 @@ Parameters:
|
|||||||
- `buf` - a data to send to the pipe connection. Use `""` if there is no data
|
- `buf` - a data to send to the pipe connection. Use `""` if there is no data
|
||||||
- `len` - a data length
|
- `len` - a data length
|
||||||
|
|
||||||
Return value: None
|
Return value: `true` if data has been sent, `false` otherwise
|
||||||
|
|
||||||
Usage example: see [examples/multi-threaded](https://github.com/cesanta/mongoose/tree/master/examples/multi-threaded).
|
Usage example: see [examples/multi-threaded](https://github.com/cesanta/mongoose/tree/master/examples/multi-threaded).
|
||||||
|
|
||||||
|
@ -3542,11 +3542,10 @@ static bool mg_socketpair(SOCKET sp[2], union usa usa[2]) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mg_mgr_wakeup(struct mg_connection *c, const void *buf, size_t len) {
|
bool mg_mgr_wakeup(struct mg_connection *c, const void *buf, size_t len) {
|
||||||
if (buf == NULL || len == 0) buf = (void *) "", len = 1;
|
if (buf == NULL || len == 0) buf = (void *) "", len = 1;
|
||||||
if ((size_t) send((SOCKET) (size_t) c->pfn_data, (const char *) buf, len,
|
return (size_t) send((SOCKET) (size_t) c->pfn_data, (const char *) buf, len,
|
||||||
MSG_NONBLOCKING) != len)
|
MSG_NONBLOCKING) == len;
|
||||||
(void) 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pf1(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
static void pf1(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||||
|
@ -953,7 +953,7 @@ bool mg_aton(struct mg_str str, struct mg_addr *addr);
|
|||||||
char *mg_ntoa(const struct mg_addr *addr, char *buf, size_t len);
|
char *mg_ntoa(const struct mg_addr *addr, char *buf, size_t len);
|
||||||
|
|
||||||
struct mg_connection *mg_mkpipe(struct mg_mgr *, mg_event_handler_t, void *);
|
struct mg_connection *mg_mkpipe(struct mg_mgr *, mg_event_handler_t, void *);
|
||||||
void mg_mgr_wakeup(struct mg_connection *pipe, const void *buf, size_t len);
|
bool mg_mgr_wakeup(struct mg_connection *pipe, const void *buf, size_t len);
|
||||||
|
|
||||||
// These functions are used to integrate with custom network stacks
|
// These functions are used to integrate with custom network stacks
|
||||||
struct mg_connection *mg_alloc_conn(struct mg_mgr *);
|
struct mg_connection *mg_alloc_conn(struct mg_mgr *);
|
||||||
|
@ -77,7 +77,7 @@ bool mg_aton(struct mg_str str, struct mg_addr *addr);
|
|||||||
char *mg_ntoa(const struct mg_addr *addr, char *buf, size_t len);
|
char *mg_ntoa(const struct mg_addr *addr, char *buf, size_t len);
|
||||||
|
|
||||||
struct mg_connection *mg_mkpipe(struct mg_mgr *, mg_event_handler_t, void *);
|
struct mg_connection *mg_mkpipe(struct mg_mgr *, mg_event_handler_t, void *);
|
||||||
void mg_mgr_wakeup(struct mg_connection *pipe, const void *buf, size_t len);
|
bool mg_mgr_wakeup(struct mg_connection *pipe, const void *buf, size_t len);
|
||||||
|
|
||||||
// These functions are used to integrate with custom network stacks
|
// These functions are used to integrate with custom network stacks
|
||||||
struct mg_connection *mg_alloc_conn(struct mg_mgr *);
|
struct mg_connection *mg_alloc_conn(struct mg_mgr *);
|
||||||
|
@ -413,11 +413,10 @@ static bool mg_socketpair(SOCKET sp[2], union usa usa[2]) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mg_mgr_wakeup(struct mg_connection *c, const void *buf, size_t len) {
|
bool mg_mgr_wakeup(struct mg_connection *c, const void *buf, size_t len) {
|
||||||
if (buf == NULL || len == 0) buf = (void *) "", len = 1;
|
if (buf == NULL || len == 0) buf = (void *) "", len = 1;
|
||||||
if ((size_t) send((SOCKET) (size_t) c->pfn_data, (const char *) buf, len,
|
return (size_t) send((SOCKET) (size_t) c->pfn_data, (const char *) buf, len,
|
||||||
MSG_NONBLOCKING) != len)
|
MSG_NONBLOCKING) == len;
|
||||||
(void) 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pf1(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
static void pf1(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user