comparison src/c/urweb.c @ 687:a3ddf05fb3e3

On start-up, delete/nullify rows mentioning clients or channels
author Adam Chlipala <adamc@hcoop.net>
date Thu, 02 Apr 2009 11:42:26 -0400
parents c73c5fe72388
children b6a8425e1b1f
comparison
equal deleted inserted replaced
686:3b46548f701b 687:a3ddf05fb3e3
306 char error_message[ERROR_BUF_LEN]; 306 char error_message[ERROR_BUF_LEN];
307 }; 307 };
308 308
309 extern int uw_inputs_len, uw_timeout; 309 extern int uw_inputs_len, uw_timeout;
310 310
311 uw_context uw_init(size_t outHeaders_len, size_t script_len, size_t page_len, size_t heap_len) { 311 uw_context uw_init() {
312 uw_context ctx = malloc(sizeof(struct uw_context)); 312 uw_context ctx = malloc(sizeof(struct uw_context));
313 313
314 ctx->headers = ctx->headers_end = NULL; 314 ctx->headers = ctx->headers_end = NULL;
315 315
316 buf_init(&ctx->outHeaders, outHeaders_len); 316 buf_init(&ctx->outHeaders, 0);
317 buf_init(&ctx->page, page_len); 317 buf_init(&ctx->page, 0);
318 buf_init(&ctx->heap, heap_len); 318 buf_init(&ctx->heap, 0);
319 buf_init(&ctx->script, script_len); 319 buf_init(&ctx->script, 0);
320 ctx->script.start[0] = 0; 320 ctx->script.start[0] = 0;
321 321
322 ctx->inputs = calloc(uw_inputs_len, sizeof(char *)); 322 ctx->inputs = calloc(uw_inputs_len, sizeof(char *));
323 323
324 ctx->db = NULL; 324 ctx->db = NULL;
1929 pthread_mutex_unlock(&c->lock); 1929 pthread_mutex_unlock(&c->lock);
1930 } 1930 }
1931 1931
1932 pthread_mutex_unlock(&clients_mutex); 1932 pthread_mutex_unlock(&clients_mutex);
1933 } 1933 }
1934
1935 void uw_initializer(uw_context ctx);
1936
1937 failure_kind uw_initialize(uw_context ctx) {
1938 int r = setjmp(ctx->jmp_buf);
1939
1940 if (r == 0) {
1941 if (uw_db_begin(ctx))
1942 uw_error(ctx, FATAL, "Error running SQL BEGIN");
1943 uw_initializer(ctx);
1944 if (uw_db_commit(ctx))
1945 uw_error(ctx, FATAL, "Error running SQL COMMIT");
1946 }
1947
1948 return r;
1949 }