Permalink
Browse files

allow '*' as a subscriber name that implies trust of the CN connectin…

…g requesting a durable stream
  • Loading branch information...
1 parent 0178e0e commit 927b6f98514ba97b2d11bb1389585fa571da5e47 @postwait postwait committed Feb 20, 2013
Showing with 19 additions and 6 deletions.
  1. +13 −2 src/noit_jlog_listener.c
  2. +5 −3 src/utils/noit_log.c
  3. +1 −1 test/t/testconfig.pm
View
@@ -303,6 +303,7 @@ noit_jlog_handler(eventer_t e, int mask, void *closure,
if(!ac->service_ctx) {
noit_log_stream_t ls;
const char *logname, *type;
+ int first_attempt = 1;
char path[PATH_MAX], subscriber[256], *sub;
jcl = ac->service_ctx = noit_jlog_closure_alloc();
if(!noit_hash_retr_str(ac->config,
@@ -351,20 +352,30 @@ noit_jlog_handler(eventer_t e, int mask, void *closure,
char *esub = strchr(sub, ')');
if(esub) {
*esub = '\0';
- *sub = '\0';
+ *sub++ = '\0';
}
}
jcl->jlog = jlog_new(path);
- if(ac->cmd == NOIT_JLOG_DATA_TEMP_FEED)
+ if(ac->cmd == NOIT_JLOG_DATA_TEMP_FEED) {
+ add_sub:
if(jlog_ctx_add_subscriber(jcl->jlog, jcl->subscriber, JLOG_END) == -1) {
snprintf(errbuff, sizeof(errbuff),
"jlog reader[%s] error: %s", jcl->subscriber,
jlog_ctx_err_string(jcl->jlog));
errstr = errbuff;
noitL(noit_error, "%s\n", errstr);
}
+ }
if(jlog_ctx_open_reader(jcl->jlog, jcl->subscriber) == -1) {
+ if(sub && !strcmp(sub, "*")) {
+ if(first_attempt) {
+ jlog_ctx_close(jcl->jlog);
+ jcl->jlog = jlog_new(path);
+ first_attempt = 0;
+ goto add_sub;
+ }
+ }
snprintf(errbuff, sizeof(errbuff),
"jlog reader[%s] error: %s", jcl->subscriber,
jlog_ctx_err_string(jcl->jlog));
View
@@ -454,7 +454,7 @@ jlog_logio_open(noit_log_stream_t ls) {
jlog_asynch_ctx *actx;
jlog_ctx *log = NULL;
pthread_attr_t tattr;
- int i, listed, found;
+ int i, listed, found, allow_unmatched = 0;
if(jlog_lspath_to_fspath(ls, path, sizeof(path), &sub) <= 0) return -1;
log = jlog_new(path);
@@ -497,20 +497,22 @@ jlog_logio_open(noit_log_stream_t ls) {
if(sub) {
/* Match all configured subscribers against jlog's list. */
for(p=strtok(sub, ",");p;p=strtok(NULL, ",")) {
+ if(!strcmp(p,"*")) allow_unmatched = 1;
for(i=0;i<listed;i++) {
if((subs[i]) && (strcmp(p, subs[i]) == 0)) {
free(subs[i]);
subs[i] = NULL;
break;
}
}
- if(i == listed)
+ if(i == listed && strcmp(p,"*"))
jlog_ctx_add_subscriber(log, p, JLOG_BEGIN);
}
/* Remove all unmatched subscribers. */
for(i=0;i<listed;i++) {
- if(subs[i]) {
+ if(subs[i] &&
+ (!allow_unmatched || subs[i][0] == '~')) {
jlog_ctx_remove_subscriber(log, subs[i]);
free(subs[i]);
subs[i] = NULL;
View
@@ -142,7 +142,7 @@ sub make_logs_config {
<log name="debug" disabled="$opts->{logs_debug}->{''}" timestamps="true"/>
</console_output>
<feeds>
- <log name="feed" type="jlog" path="$cwd/logs/$opts->{name}.feed(stratcon)"/>
+ <log name="feed" type="jlog" path="$cwd/logs/$opts->{name}.feed(*)"/>
</feeds>
<components>
};

0 comments on commit 927b6f9

Please sign in to comment.