summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2011-04-09 20:00:52 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2011-04-09 20:00:52 -0400
commit27e97143b6e20274484289ad61bfd9eb1922d50a (patch)
treeafc1aa975eca7a387cdc88de716b920780ba4c89 /src
parent51b2033057b25f4cecd3d5e73dc49b60b532834e (diff)
Send newly created sources with messages to clients
Diffstat (limited to 'src')
-rw-r--r--src/c/http.c2
-rw-r--r--src/c/urweb.c15
2 files changed, 13 insertions, 4 deletions
diff --git a/src/c/http.c b/src/c/http.c
index 579c874e..4b2f0576 100644
--- a/src/c/http.c
+++ b/src/c/http.c
@@ -198,7 +198,7 @@ static void *worker(void *data) {
on_success, on_failure,
NULL, log_error, log_debug,
sock, uw_really_send, close);
- uw_send(ctx, sock);
+ if (rr != KEEP_OPEN) uw_send(ctx, sock);
if (rr == SERVED || rr == FAILED)
close(sock);
diff --git a/src/c/urweb.c b/src/c/urweb.c
index 582aaf29..0bc739fc 100644
--- a/src/c/urweb.c
+++ b/src/c/urweb.c
@@ -311,16 +311,25 @@ static uw_Basis_channel new_channel(client *c) {
return ch;
}
-static void client_send(client *c, uw_buffer *msg) {
+static void client_send(client *c, uw_buffer *msg, const char *script, int script_len) {
pthread_mutex_lock(&c->lock);
if (c->sock != -1) {
c->send(c->sock, on_success, strlen(on_success));
c->send(c->sock, begin_msgs, sizeof(begin_msgs) - 1);
+ if (script_len > 0) {
+ c->send(c->sock, "E\n", 2);
+ c->send(c->sock, script, script_len);
+ c->send(c->sock, "\n", 1);
+ }
c->send(c->sock, msg->start, uw_buffer_used(msg));
c->close(c->sock);
c->sock = -1;
- } else if (uw_buffer_append(&c->msgs, msg->start, uw_buffer_used(msg)))
+ } else if ((script_len > 0
+ && (c->send(c->sock, "E\n", 2)
+ || c->send(c->sock, script, script_len)
+ || c->send(c->sock, "\n", 1)))
+ || uw_buffer_append(&c->msgs, msg->start, uw_buffer_used(msg)))
fprintf(stderr, "Client message buffer size exceeded");
pthread_mutex_unlock(&c->lock);
@@ -3167,7 +3176,7 @@ void uw_commit(uw_context ctx) {
assert (c != NULL && c->mode == USED);
- client_send(c, &d->msgs);
+ client_send(c, &d->msgs, ctx->script.start, uw_buffer_used(&ctx->script));
}
if (ctx->client)