View | Details | Raw Unified | Return to bug 186114 | Differences between
and this patch

Collapse All | Expand All

(-)src/console.h (+1 lines)
Lines 119-124 Link Here
119
  extern int	ConsoleStat(Context ctx, int ac, char *av[], void *arg);
119
  extern int	ConsoleStat(Context ctx, int ac, char *av[], void *arg);
120
  extern Context	StdConsoleConnect(Console c);
120
  extern Context	StdConsoleConnect(Console c);
121
  extern void	ConsoleShutdown(Console c);
121
  extern void	ConsoleShutdown(Console c);
122
  extern void	ConsoleCancelCleanup(void *rwlock);
122
123
123
  extern int	UserCommand(Context ctx, int ac, char *av[], void *arg);
124
  extern int	UserCommand(Context ctx, int ac, char *av[], void *arg);
124
  extern int	UserStat(Context ctx, int ac, char *av[], void *arg);
125
  extern int	UserStat(Context ctx, int ac, char *av[], void *arg);
(-)src/console.c (-2 / +12 lines)
Lines 175-180 ConsoleClose(Console c) Link Here
175
  return 0;
175
  return 0;
176
}
176
}
177
177
178
void
179
ConsoleCancelCleanup(void *rwlock)
180
{
181
  pthread_rwlock_t p = (pthread_rwlock_t)rwlock;
182
183
  RWLOCK_UNLOCK(p);
184
}
185
178
/*
186
/*
179
 * ConsoleStat()
187
 * ConsoleStat()
180
 */
188
 */
Lines 192-204 ConsoleStat(Context ctx, int ac, char *a Link Here
192
  Printf("\tIP-Address    : %s\r\n", u_addrtoa(&c->addr,addrstr,sizeof(addrstr)));
200
  Printf("\tIP-Address    : %s\r\n", u_addrtoa(&c->addr,addrstr,sizeof(addrstr)));
193
  Printf("\tPort          : %d\r\n", c->port);
201
  Printf("\tPort          : %d\r\n", c->port);
194
202
203
  pthread_cleanup_push(ConsoleCancelCleanup, c->lock);
195
  RWLOCK_RDLOCK(c->lock);
204
  RWLOCK_RDLOCK(c->lock);
196
  Printf("Active sessions:\r\n");
205
  Printf("Active sessions:\r\n");
197
  SLIST_FOREACH(s, &c->sessions, next) {
206
  SLIST_FOREACH(s, &c->sessions, next) {
198
    Printf("\tUsername: %s\tFrom: %s\r\n",
207
    Printf("\tUsername: %s\tFrom: %s\r\n",
199
	s->user.username, u_addrtoa(&s->peer_addr,addrstr,sizeof(addrstr)));
208
	s->user.username, u_addrtoa(&s->peer_addr,addrstr,sizeof(addrstr)));
200
  }
209
  }
201
  RWLOCK_UNLOCK(c->lock);
210
  pthread_cleanup_pop(1);
202
211
203
  Printf("Global options:\r\n");
212
  Printf("Global options:\r\n");
204
  OptStat(ctx, &c->options, gConfList);
213
  OptStat(ctx, &c->options, gConfList);
Lines 905-917 UserStat(Context ctx, int ac, char *av[] Link Here
905
    ConsoleUser		u;
914
    ConsoleUser		u;
906
915
907
    Printf("Configured users:\r\n");
916
    Printf("Configured users:\r\n");
917
    pthread_cleanup_push(ConsoleCancelCleanup, gUsersLock);
908
    RWLOCK_RDLOCK(gUsersLock);
918
    RWLOCK_RDLOCK(gUsersLock);
909
    ghash_walk_init(gUsers, &walk);
919
    ghash_walk_init(gUsers, &walk);
910
    while ((u = ghash_walk_next(gUsers, &walk)) !=  NULL) {
920
    while ((u = ghash_walk_next(gUsers, &walk)) !=  NULL) {
911
	Printf("\tUsername: %-15s Priv: %s\r\n", u->username,
921
	Printf("\tUsername: %-15s Priv: %s\r\n", u->username,
912
	    ((u->priv == 2)?"admin":((u->priv == 1)?"operator":"user")));
922
	    ((u->priv == 2)?"admin":((u->priv == 1)?"operator":"user")));
913
    }
923
    }
914
    RWLOCK_UNLOCK(gUsersLock);
924
    pthread_cleanup_pop(1);
915
925
916
    return 0;
926
    return 0;
917
}
927
}
(-)src/log.c (-1 / +2 lines)
Lines 256-267 vLogPrintf(const char *fmt, va_list args Link Here
256
#ifdef SYSLOG_FACILITY
256
#ifdef SYSLOG_FACILITY
257
        syslog(LOG_INFO, "%s", buf);
257
        syslog(LOG_INFO, "%s", buf);
258
#endif
258
#endif
259
	pthread_cleanup_push(ConsoleCancelCleanup, gConsole.lock);
259
	RWLOCK_RDLOCK(gConsole.lock);
260
	RWLOCK_RDLOCK(gConsole.lock);
260
	SLIST_FOREACH(s, &gConsole.sessions, next) {
261
	SLIST_FOREACH(s, &gConsole.sessions, next) {
261
	    if (Enabled(&s->options, CONSOLE_LOGGING))
262
	    if (Enabled(&s->options, CONSOLE_LOGGING))
262
		s->write(s, "%s\r\n", buf);
263
		s->write(s, "%s\r\n", buf);
263
	}
264
	}
264
	RWLOCK_UNLOCK(gConsole.lock);
265
	pthread_cleanup_pop(1);
265
#ifdef SYSLOG_FACILITY
266
#ifdef SYSLOG_FACILITY
266
    } else {
267
    } else {
267
        vsyslog(LOG_INFO, fmt, args);
268
        vsyslog(LOG_INFO, fmt, args);

Return to bug 186114