static void test_write_wantsignal(const char *testname, int sock1, int sock2) { if (shutdown(sock2, SHUT_WR) < 0) err(-1, "%s: shutdown", testname); signal_setup(testname); test_write(testname, sock2); if (!got_signal()) errx(-1, "%s: write: didn't receive SIGPIPE", testname); close(sock1); close(sock2); }
void send_sync_char() { int i=0; while(i>=0) { device_t *d = get_n_device(DT_CHAR, i); if(!d) break; assert(d->ptr); chardevice_t *cd = (chardevice_t *)d->ptr; if(cd->ioctl) cd->ioctl(0, -1, 0); i++; if(got_signal(current_task)) return; } }
static void test_write_dontsignal(const char *testname, int sock1, int sock2) { int i; i = 1; if (setsockopt(sock2, SOL_SOCKET, SO_NOSIGPIPE, &i, sizeof(i)) < 0) err(-1, "%s: setsockopt(SOL_SOCKET, SO_NOSIGPIPE)", testname); if (shutdown(sock2, SHUT_WR) < 0) err(-1, "%s: shutdown", testname); signal_setup(testname); test_write(testname, sock2); if (got_signal()) errx(-1, "%s: write: got SIGPIPE", testname); close(sock1); close(sock2); }
void sync_cache(cache_t *c) { if(!c->dirty || !c->sync) return; accessed_cache(c); printk(0, "[cache]: Cache '%s' is syncing\n", c->name); volatile unsigned int num = c->dirty; volatile unsigned int i=1; struct ce_t *obj; c->syncing=1; while(c->dirty > 0) { rwlock_acquire(c->rwl, RWL_WRITER); if(c->dirty == 0) { c->syncing = 0; rwlock_release(c->rwl, RWL_WRITER); break; } assert(c->dirty_ll.head); obj = c->dirty_ll.head->entry; if(num < (c->dirty+i)) num=(c->dirty+i); printk((kernel_state_flags & KSF_SHUTDOWN) ? 4 : 0, "\r[cache]: Syncing '%s': %d/%d (%d.%d%%)... " ,c->name, i, num, (i*100)/num, ((i*1000)/num) % 10); do_sync_element(c, obj, 1); rwlock_release(c->rwl, RWL_WRITER); if(got_signal(current_task)) return; i++; } c->syncing=0; printk((kernel_state_flags & KSF_SHUTDOWN) ? 4 : 0, "\r[cache]: Syncing '%s': %d/%d (%d.%d%%)\n" , c->name, num, num, 100, 0); printk(0, "[cache]: Cache '%s' has sunk\n", c->name); }