mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Don't crash when looking at NULL clients; also redraw everything on status change.
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: cmd-set-option.c,v 1.20 2008-06-04 05:40:35 nicm Exp $ */
 | 
			
		||||
/* $Id: cmd-set-option.c,v 1.21 2008-06-04 05:47:46 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -180,12 +180,10 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
 | 
			
		||||
		colour |= number << 4;
 | 
			
		||||
		options_set_number(oo, "status-colour", colour);
 | 
			
		||||
 | 
			
		||||
		if (options_get_number(oo, "status-lines") > 0) {
 | 
			
		||||
			for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
			
		||||
				c = ARRAY_ITEM(&clients, i);
 | 
			
		||||
				if (c != NULL && c->session != NULL)
 | 
			
		||||
					server_redraw_client(c);
 | 
			
		||||
			}
 | 
			
		||||
		for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
			
		||||
			c = ARRAY_ITEM(&clients, i);
 | 
			
		||||
			if (c != NULL && c->session != NULL)
 | 
			
		||||
				server_redraw_client(c);
 | 
			
		||||
		}
 | 
			
		||||
	} else if (strcmp(data->option, "status-bg") == 0) {
 | 
			
		||||
		if (data->value == NULL) {
 | 
			
		||||
@@ -203,12 +201,10 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
 | 
			
		||||
		colour |= number;
 | 
			
		||||
		options_set_number(oo, "status-colour", colour);
 | 
			
		||||
 | 
			
		||||
		if (options_get_number(oo, "status-lines") > 0) {
 | 
			
		||||
			for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
			
		||||
				c = ARRAY_ITEM(&clients, i);
 | 
			
		||||
				if (c != NULL && c->session != NULL)
 | 
			
		||||
					server_redraw_client(c);
 | 
			
		||||
			}
 | 
			
		||||
		for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
			
		||||
			c = ARRAY_ITEM(&clients, i);
 | 
			
		||||
			if (c != NULL && c->session != NULL)
 | 
			
		||||
				server_redraw_client(c);
 | 
			
		||||
		}
 | 
			
		||||
	} else if (strcmp(data->option, "bell-action") == 0) {
 | 
			
		||||
		if (data->value == NULL) {
 | 
			
		||||
@@ -247,13 +243,27 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
 | 
			
		||||
			ctx->error(ctx, "invalid value");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		options_set_string(oo, "status-left", "%s", data->value);
 | 
			
		||||
 | 
			
		||||
		for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
			
		||||
			c = ARRAY_ITEM(&clients, i);
 | 
			
		||||
			if (c != NULL && c->session != NULL)
 | 
			
		||||
				server_redraw_client(c);
 | 
			
		||||
		}
 | 
			
		||||
	} else if (strcmp(data->option, "status-right") == 0) {
 | 
			
		||||
		if (data->value == NULL) {
 | 
			
		||||
			ctx->error(ctx, "invalid value");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		options_set_string(oo, "status-right", "%s", data->value);
 | 
			
		||||
 | 
			
		||||
		for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
			
		||||
			c = ARRAY_ITEM(&clients, i);
 | 
			
		||||
			if (c != NULL && c->session != NULL)
 | 
			
		||||
				server_redraw_client(c);
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		ctx->error(ctx, "unknown option: %s", data->option);
 | 
			
		||||
		return;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										19
									
								
								server.c
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								server.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
			
		||||
/* $Id: server.c,v 1.50 2008-06-04 05:40:35 nicm Exp $ */
 | 
			
		||||
/* $Id: server.c,v 1.51 2008-06-04 05:47:46 nicm Exp $ */
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
			
		||||
@@ -296,16 +296,15 @@ server_handle_clients(struct pollfd **pfd)
 | 
			
		||||
	for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
			
		||||
		c = ARRAY_ITEM(&clients, i);
 | 
			
		||||
 | 
			
		||||
		/* XXX REDRAW FLAGS */
 | 
			
		||||
		if (c->session != NULL && options_get_number(
 | 
			
		||||
		    &c->session->options, "status-lines") != 0) {
 | 
			
		||||
			if (clock_gettime(CLOCK_REALTIME, &now) != 0)
 | 
			
		||||
				fatal("clock_gettime");
 | 
			
		||||
			if (timespeccmp(&now, &c->status_ts, >))
 | 
			
		||||
				server_status_client(c);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (c != NULL) {
 | 
			
		||||
			if (c->session != NULL && options_get_number(
 | 
			
		||||
			    &c->session->options, "status-lines") != 0) {
 | 
			
		||||
				if (clock_gettime(CLOCK_REALTIME, &now) != 0)
 | 
			
		||||
					fatal("clock_gettime");
 | 
			
		||||
				if (timespeccmp(&now, &c->status_ts, >))
 | 
			
		||||
					server_status_client(c);
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			log_debug("testing client %d (%d)", (*pfd)->fd, c->fd);
 | 
			
		||||
			if (buffer_poll(*pfd, c->in, c->out) != 0) {
 | 
			
		||||
				server_lost_client(c);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user