mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
/UPGRADE didn't work properly when you were connected to multiple servers.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2080 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
5656ad352d
commit
78f9c141dc
@ -198,11 +198,11 @@ static void server_connect_callback_readpipe(SERVER_REC *server)
|
|||||||
|
|
||||||
handle = NULL;
|
handle = NULL;
|
||||||
if (ip != NULL) {
|
if (ip != NULL) {
|
||||||
/* allow "server connecting" signal to create the
|
signal_emit("server connecting", 2, server, ip);
|
||||||
connection handle */
|
if (server->handle == NULL)
|
||||||
signal_emit("server connecting", 3, server, ip, &handle);
|
|
||||||
if (handle == NULL)
|
|
||||||
handle = net_connect_ip(ip, port, own_ip);
|
handle = net_connect_ip(ip, port, own_ip);
|
||||||
|
else
|
||||||
|
handle = net_sendbuffer_handle(server->handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle == NULL) {
|
if (handle == NULL) {
|
||||||
@ -227,6 +227,7 @@ static void server_connect_callback_readpipe(SERVER_REC *server)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (server->handle == NULL)
|
||||||
server->handle = net_sendbuffer_create(handle, 0);
|
server->handle = net_sendbuffer_create(handle, 0);
|
||||||
server->connect_tag =
|
server->connect_tag =
|
||||||
g_input_add(handle, G_INPUT_WRITE | G_INPUT_READ,
|
g_input_add(handle, G_INPUT_WRITE | G_INPUT_READ,
|
||||||
|
@ -32,8 +32,6 @@
|
|||||||
static char *session_file;
|
static char *session_file;
|
||||||
static char *irssi_binary;
|
static char *irssi_binary;
|
||||||
|
|
||||||
static GIOChannel *next_handle;
|
|
||||||
|
|
||||||
void session_set_binary(const char *path)
|
void session_set_binary(const char *path)
|
||||||
{
|
{
|
||||||
char **paths, **tmp;
|
char **paths, **tmp;
|
||||||
@ -73,21 +71,18 @@ static void cmd_upgrade(const char *data)
|
|||||||
{
|
{
|
||||||
CONFIG_REC *session;
|
CONFIG_REC *session;
|
||||||
GSList *file_handles;
|
GSList *file_handles;
|
||||||
const char *args[10];
|
char *session_file, *str, **args;
|
||||||
char *session_file;
|
int i;
|
||||||
int n;
|
|
||||||
|
|
||||||
if (*data == '\0')
|
if (*data == '\0')
|
||||||
data = irssi_binary;
|
data = irssi_binary;
|
||||||
|
if (data == NULL)
|
||||||
/* make sure we can execute it */
|
cmd_return_error(CMDERR_NOT_ENOUGH_PARAMS);
|
||||||
if (data == NULL || access(data, X_OK) != 0)
|
|
||||||
cmd_return_error(CMDERR_ERRNO);
|
|
||||||
|
|
||||||
/* save the session */
|
/* save the session */
|
||||||
session_file = g_strdup_printf("%s/session.%d", get_irssi_dir(), getpid());
|
session_file = g_strdup_printf("%s/session.%d", get_irssi_dir(), getpid());
|
||||||
unlink(session_file);
|
|
||||||
session = config_open(session_file, 0600);
|
session = config_open(session_file, 0600);
|
||||||
|
unlink(session_file);
|
||||||
|
|
||||||
file_handles = NULL;
|
file_handles = NULL;
|
||||||
signal_emit("session save", 2, session, &file_handles);
|
signal_emit("session save", 2, session, &file_handles);
|
||||||
@ -98,18 +93,19 @@ static void cmd_upgrade(const char *data)
|
|||||||
signal_emit("session clean", 0);
|
signal_emit("session clean", 0);
|
||||||
|
|
||||||
/* close the file handles we don't want to transfer to new client */
|
/* close the file handles we don't want to transfer to new client */
|
||||||
for (n = 3; n < 256; n++) {
|
for (i = 3; i < 256; i++) {
|
||||||
if (g_slist_find(file_handles, GINT_TO_POINTER(n)) == NULL)
|
if (g_slist_find(file_handles, GINT_TO_POINTER(i)) == NULL)
|
||||||
close(n);
|
close(i);
|
||||||
}
|
}
|
||||||
g_slist_free(file_handles),
|
g_slist_free(file_handles),
|
||||||
|
|
||||||
/* irssi --session ~/.irssi/session.<pid> -! */
|
/* irssi -! --session ~/.irssi/session.<pid>
|
||||||
args[0] = data;
|
data may contain some other program as well, like
|
||||||
args[1] = "--session";
|
/UPGRADE /usr/bin/screen irssi */
|
||||||
args[2] = session_file;
|
str = g_strdup_printf("%s -! --session %s", data, session_file);
|
||||||
args[3] = "-!";
|
args = g_strsplit(str, " ", -1);
|
||||||
args[4] = NULL;
|
g_free(str);
|
||||||
|
|
||||||
execvp(args[0], (char **) args);
|
execvp(args[0], (char **) args);
|
||||||
|
|
||||||
fprintf(stderr, "exec: %s: %s\n", args[0], g_strerror(errno));
|
fprintf(stderr, "exec: %s: %s\n", args[0], g_strerror(errno));
|
||||||
@ -165,10 +161,10 @@ static void session_restore_server(CONFIG_NODE *node)
|
|||||||
conn = server_create_conn(proto->id, address, port,
|
conn = server_create_conn(proto->id, address, port,
|
||||||
chatnet, password, nick);
|
chatnet, password, nick);
|
||||||
if (conn != NULL) {
|
if (conn != NULL) {
|
||||||
next_handle = g_io_channel_unix_new(handle);
|
|
||||||
conn->reconnection = TRUE;
|
conn->reconnection = TRUE;
|
||||||
|
|
||||||
server = proto->server_connect(conn);
|
server = proto->server_connect(conn);
|
||||||
|
server->handle = net_sendbuffer_create(g_io_channel_unix_new(handle), 0);
|
||||||
server->session_reconnect = TRUE;
|
server->session_reconnect = TRUE;
|
||||||
|
|
||||||
signal_emit("session restore server", 2, server, node);
|
signal_emit("session restore server", 2, server, node);
|
||||||
@ -216,12 +212,6 @@ static void sig_init_finished(void)
|
|||||||
session_file = NULL;
|
session_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sig_connecting(SERVER_REC *server, IPADDR *ip, GIOChannel **handle)
|
|
||||||
{
|
|
||||||
*handle = next_handle;
|
|
||||||
next_handle = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void session_init(void)
|
void session_init(void)
|
||||||
{
|
{
|
||||||
static struct poptOption options[] = {
|
static struct poptOption options[] = {
|
||||||
@ -237,8 +227,6 @@ void session_init(void)
|
|||||||
signal_add("session save", (SIGNAL_FUNC) sig_session_save);
|
signal_add("session save", (SIGNAL_FUNC) sig_session_save);
|
||||||
signal_add("session restore", (SIGNAL_FUNC) sig_session_restore);
|
signal_add("session restore", (SIGNAL_FUNC) sig_session_restore);
|
||||||
signal_add("irssi init finished", (SIGNAL_FUNC) sig_init_finished);
|
signal_add("irssi init finished", (SIGNAL_FUNC) sig_init_finished);
|
||||||
|
|
||||||
signal_add("server connecting", (SIGNAL_FUNC) sig_connecting);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_deinit(void)
|
void session_deinit(void)
|
||||||
@ -250,6 +238,4 @@ void session_deinit(void)
|
|||||||
signal_remove("session save", (SIGNAL_FUNC) sig_session_save);
|
signal_remove("session save", (SIGNAL_FUNC) sig_session_save);
|
||||||
signal_remove("session restore", (SIGNAL_FUNC) sig_session_restore);
|
signal_remove("session restore", (SIGNAL_FUNC) sig_session_restore);
|
||||||
signal_remove("irssi init finished", (SIGNAL_FUNC) sig_init_finished);
|
signal_remove("irssi init finished", (SIGNAL_FUNC) sig_init_finished);
|
||||||
|
|
||||||
signal_remove("server connecting", (SIGNAL_FUNC) sig_connecting);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user