Mercurial > urweb
comparison src/c/urweb.c @ 684:f0224c7f12bb
Expunging nullable fields
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 29 Mar 2009 14:13:50 -0400 |
parents | 9a2c18dab11d |
children | c73c5fe72388 |
comparison
equal
deleted
inserted
replaced
683:9a2c18dab11d | 684:f0224c7f12bb |
---|---|
1867 void uw_expunger(uw_context ctx, uw_Basis_client cli); | 1867 void uw_expunger(uw_context ctx, uw_Basis_client cli); |
1868 | 1868 |
1869 static failure_kind uw_expunge(uw_context ctx, uw_Basis_client cli) { | 1869 static failure_kind uw_expunge(uw_context ctx, uw_Basis_client cli) { |
1870 int r = setjmp(ctx->jmp_buf); | 1870 int r = setjmp(ctx->jmp_buf); |
1871 | 1871 |
1872 if (r == 0) | 1872 if (r == 0) { |
1873 if (uw_db_begin(ctx)) | |
1874 uw_error(ctx, FATAL, "Error running SQL BEGIN"); | |
1873 uw_expunger(ctx, cli); | 1875 uw_expunger(ctx, cli); |
1876 if (uw_db_commit(ctx)) | |
1877 uw_error(ctx, FATAL, "Error running SQL COMMIT"); | |
1878 } | |
1874 | 1879 |
1875 return r; | 1880 return r; |
1876 } | 1881 } |
1877 | 1882 |
1878 void uw_prune_clients(uw_context ctx) { | 1883 void uw_prune_clients(uw_context ctx) { |
1890 failure_kind fk = UNLIMITED_RETRY; | 1895 failure_kind fk = UNLIMITED_RETRY; |
1891 if (prev) | 1896 if (prev) |
1892 prev->next = next; | 1897 prev->next = next; |
1893 else | 1898 else |
1894 clients_used = next; | 1899 clients_used = next; |
1900 uw_reset(ctx); | |
1895 while (fk == UNLIMITED_RETRY) { | 1901 while (fk == UNLIMITED_RETRY) { |
1896 uw_reset(ctx); | |
1897 fk = uw_expunge(ctx, c->id); | 1902 fk = uw_expunge(ctx, c->id); |
1898 if (fk == SUCCESS) { | 1903 if (fk == UNLIMITED_RETRY) { |
1899 free_client(c); | 1904 uw_db_rollback(ctx); |
1900 break; | 1905 printf("Unlimited retry during expunge: %s\n", uw_error_message(ctx)); |
1901 } | 1906 } |
1902 } | 1907 } |
1903 if (fk != SUCCESS) | 1908 if (fk == SUCCESS) |
1909 free_client(c); | |
1910 else { | |
1911 uw_db_rollback(ctx); | |
1904 printf("Expunge blocked by error: %s\n", uw_error_message(ctx)); | 1912 printf("Expunge blocked by error: %s\n", uw_error_message(ctx)); |
1913 } | |
1905 } | 1914 } |
1906 else | 1915 else |
1907 prev = c; | 1916 prev = c; |
1908 pthread_mutex_unlock(&c->lock); | 1917 pthread_mutex_unlock(&c->lock); |
1909 } | 1918 } |