Permalink
Browse files

If this is a new tube then create a new Announce tube using -A NAME a…

…nd name being the Announce tube name
  • Loading branch information...
BiGMiCR0 committed Jul 17, 2017
1 parent b7b4a6a commit df6f115cb90e24e0bc573ce33677e3061dabd4f5
Showing with 25 additions and 0 deletions.
  1. +2 −0 dat.h
  2. +18 −0 prot.c
  3. +5 −0 util.c
View
2 dat.h
@@ -335,6 +335,8 @@ struct Wal {
int64 syncrate;
int64 lastsync;
int nocomp; // disable binlog compaction?
int duplicate;
char *duplicatename;
};
int waldirlock(Wal*);
void walinit(Wal*, job list);
View
18 prot.c
@@ -1193,6 +1193,7 @@ dispatch_cmd(Conn *c)
int64 delay, ttr;
uint64 id;
tube t = NULL;
int is_new_tube = 0;
/* NUL-terminate this string so we can use strtol and friends */
c->cmd[c->cmd_len - 2] = '\0';
@@ -1525,6 +1526,12 @@ dispatch_cmd(Conn *c)
if (!name_is_ok(name, 200)) return reply_msg(c, MSG_BAD_FORMAT);
op_ct[type]++;
if (!tube_find(name)) {
is_new_tube = 1;
}else{
is_new_tube = 0;
}
TUBE_ASSIGN(t, tube_find_or_make(name));
if (!t) return reply_serr(c, MSG_OUT_OF_MEMORY);
@@ -1534,6 +1541,17 @@ dispatch_cmd(Conn *c)
c->use->using_ct++;
reply_line(c, STATE_SENDWORD, "USING %s\r\n", c->use->name);
if (is_new_tube == 1){
if (c->srv->wal.duplicate){
TUBE_ASSIGN(t, tube_find_or_make(c->srv->wal.duplicatename));
connsetproducer(c);
c->in_job = make_job(5, 0, 1000000000, strlen(strcat(name , "\r\n")) , t);
memcpy(c->in_job->body, strcat(name , "\r\n"), strlen(strcat(name , "\r\n")) );
enqueue_incoming_job(c);
TUBE_ASSIGN(t, NULL);
}
}
break;
case OP_WATCH:
name = c->cmd + CMD_WATCH_LEN;
View
5 util.c
@@ -99,6 +99,7 @@ usage(int code)
fprintf(stderr, "Use: %s [OPTIONS]\n"
"\n"
"Options:\n"
" -A NAME Announce when a new tube is created on tube [NAME] \n"
" -b DIR write-ahead log directory\n"
" -f MS fsync at most once every MS milliseconds"
" (use -f0 for \"always fsync\")\n"
@@ -153,6 +154,10 @@ optparse(Server *s, char **argv)
while ((arg = *argv++) && *arg++ == '-' && *arg) {
while ((c = *arg++)) {
switch (c) {
case 'A':
s->wal.duplicate = 1;
s->wal.duplicatename = EARGF(flagusage("-A"));
break;
case 'p':
s->port = EARGF(flagusage("-p"));
warn_systemd_ignored_option("-p", s->port);

0 comments on commit df6f115

Please sign in to comment.