mirror of
https://github.com/tmux/tmux.git
synced 2025-01-15 05:09:04 +00:00
Event base does not need to be global.
This commit is contained in:
parent
b87dc608d9
commit
dd92b6e83d
10
client.c
10
client.c
@ -52,7 +52,7 @@ const char *client_exitsession;
|
|||||||
int client_attached;
|
int client_attached;
|
||||||
|
|
||||||
int client_get_lock(char *);
|
int client_get_lock(char *);
|
||||||
int client_connect(char *, int);
|
int client_connect(struct event_base *, char *, int);
|
||||||
void client_send_identify(int);
|
void client_send_identify(int);
|
||||||
int client_write_one(enum msgtype, int, const void *, size_t);
|
int client_write_one(enum msgtype, int, const void *, size_t);
|
||||||
int client_write_server(enum msgtype, const void *, size_t);
|
int client_write_server(enum msgtype, const void *, size_t);
|
||||||
@ -96,7 +96,7 @@ client_get_lock(char *lockfile)
|
|||||||
|
|
||||||
/* Connect client to server. */
|
/* Connect client to server. */
|
||||||
int
|
int
|
||||||
client_connect(char *path, int start_server)
|
client_connect(struct event_base *base, char *path, int start_server)
|
||||||
{
|
{
|
||||||
struct sockaddr_un sa;
|
struct sockaddr_un sa;
|
||||||
size_t size;
|
size_t size;
|
||||||
@ -149,7 +149,7 @@ retry:
|
|||||||
close(lockfd);
|
close(lockfd);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
fd = server_start(lockfd, lockfile);
|
fd = server_start(base, lockfd, lockfile);
|
||||||
}
|
}
|
||||||
if (locked) {
|
if (locked) {
|
||||||
free(lockfile);
|
free(lockfile);
|
||||||
@ -203,7 +203,7 @@ client_exit_message(void)
|
|||||||
|
|
||||||
/* Client main loop. */
|
/* Client main loop. */
|
||||||
int
|
int
|
||||||
client_main(int argc, char **argv, int flags)
|
client_main(struct event_base *base, int argc, char **argv, int flags)
|
||||||
{
|
{
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
@ -252,7 +252,7 @@ client_main(int argc, char **argv, int flags)
|
|||||||
set_signals(client_signal);
|
set_signals(client_signal);
|
||||||
|
|
||||||
/* Initialize the client socket and start the server. */
|
/* Initialize the client socket and start the server. */
|
||||||
fd = client_connect(socket_path, cmdflags & CMD_STARTSERVER);
|
fd = client_connect(base, socket_path, cmdflags & CMD_STARTSERVER);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
if (errno == ECONNREFUSED) {
|
if (errno == ECONNREFUSED) {
|
||||||
fprintf(stderr, "no server running on %s\n",
|
fprintf(stderr, "no server running on %s\n",
|
||||||
|
4
server.c
4
server.c
@ -158,7 +158,7 @@ server_create_socket(void)
|
|||||||
|
|
||||||
/* Fork new server. */
|
/* Fork new server. */
|
||||||
int
|
int
|
||||||
server_start(int lockfd, char *lockfile)
|
server_start(struct event_base *base, int lockfd, char *lockfile)
|
||||||
{
|
{
|
||||||
int pair[2];
|
int pair[2];
|
||||||
char *cause;
|
char *cause;
|
||||||
@ -188,7 +188,7 @@ server_start(int lockfd, char *lockfile)
|
|||||||
|
|
||||||
/* event_init() was called in our parent, need to reinit. */
|
/* event_init() was called in our parent, need to reinit. */
|
||||||
clear_signals(0);
|
clear_signals(0);
|
||||||
if (event_reinit(ev_base) != 0)
|
if (event_reinit(base) != 0)
|
||||||
fatal("event_reinit failed");
|
fatal("event_reinit failed");
|
||||||
|
|
||||||
logfile("server");
|
logfile("server");
|
||||||
|
5
tmux.c
5
tmux.c
@ -41,8 +41,6 @@ struct options global_s_options; /* session options */
|
|||||||
struct options global_w_options; /* window options */
|
struct options global_w_options; /* window options */
|
||||||
struct environ global_environ;
|
struct environ global_environ;
|
||||||
|
|
||||||
struct event_base *ev_base;
|
|
||||||
|
|
||||||
char *cfg_file;
|
char *cfg_file;
|
||||||
char *shell_cmd;
|
char *shell_cmd;
|
||||||
int debug_level;
|
int debug_level;
|
||||||
@ -386,6 +384,5 @@ main(int argc, char **argv)
|
|||||||
setproctitle("%s (%s)", __progname, socket_path);
|
setproctitle("%s (%s)", __progname, socket_path);
|
||||||
|
|
||||||
/* Pass control to the client. */
|
/* Pass control to the client. */
|
||||||
ev_base = event_init();
|
exit(client_main(event_init(), argc, argv, flags));
|
||||||
exit(client_main(argc, argv, flags));
|
|
||||||
}
|
}
|
||||||
|
5
tmux.h
5
tmux.h
@ -1407,7 +1407,6 @@ extern struct options global_options;
|
|||||||
extern struct options global_s_options;
|
extern struct options global_s_options;
|
||||||
extern struct options global_w_options;
|
extern struct options global_w_options;
|
||||||
extern struct environ global_environ;
|
extern struct environ global_environ;
|
||||||
extern struct event_base *ev_base;
|
|
||||||
extern char *cfg_file;
|
extern char *cfg_file;
|
||||||
extern char *shell_cmd;
|
extern char *shell_cmd;
|
||||||
extern int debug_level;
|
extern int debug_level;
|
||||||
@ -1792,7 +1791,7 @@ int cmd_string_parse(const char *, struct cmd_list **, const char *,
|
|||||||
void cmd_wait_for_flush(void);
|
void cmd_wait_for_flush(void);
|
||||||
|
|
||||||
/* client.c */
|
/* client.c */
|
||||||
int client_main(int, char **, int);
|
int client_main(struct event_base *, int, char **, int);
|
||||||
|
|
||||||
/* key-bindings.c */
|
/* key-bindings.c */
|
||||||
RB_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp);
|
RB_PROTOTYPE(key_bindings, key_binding, entry, key_bindings_cmp);
|
||||||
@ -1829,7 +1828,7 @@ void server_clear_marked(void);
|
|||||||
int server_is_marked(struct session *, struct winlink *,
|
int server_is_marked(struct session *, struct winlink *,
|
||||||
struct window_pane *);
|
struct window_pane *);
|
||||||
int server_check_marked(void);
|
int server_check_marked(void);
|
||||||
int server_start(int, char *);
|
int server_start(struct event_base *, int, char *);
|
||||||
void server_update_socket(void);
|
void server_update_socket(void);
|
||||||
void server_add_accept(int);
|
void server_add_accept(int);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user