4 #include <sys/socket.h>
9 .filesize
= Filesizedef
,
11 .syncrate
= DEFAULT_FSYNC_MS
* 1000000,
15 // srv_acquire_wal tries to lock the wal dir specified by s->wal and
16 // replay entries from it to initialize the s state with jobs.
17 // On errors it exits from the program.
18 void srv_acquire_wal(Server
*s
) {
20 // We want to make sure that only one beanstalkd tries
21 // to use the wal directory at a time. So acquire a lock
22 // now and never release it.
23 if (!waldirlock(&s
->wal
)) {
24 twarnx("failed to lock wal dir %s", s
->wal
.dir
);
28 Job list
= {.prev
=NULL
, .next
=NULL
};
29 list
.prev
= list
.next
= &list
;
30 walinit(&s
->wal
, &list
);
31 int ok
= prot_replay(s
, &list
);
33 twarnx("failed to replay log");
44 if (sockinit() == -1) {
50 s
->sock
.f
= (Handle
)srvaccept
;
51 s
->conns
.less
= conn_less
;
52 s
->conns
.setpos
= conn_setpos
;
54 if (sockwant(&s
->sock
, 'r') == -1) {
61 int64 period
= prottick(s
);
63 int rw
= socknext(&sock
, period
);
77 srvaccept(Server
*s
, int ev
)
79 h_accept(s
->sock
.fd
, ev
, s
);