mirror of
https://github.com/irssi/irssi.git
synced 2025-02-02 15:08:01 -05:00
Try to keep the number after server tag always the same when there's
multiple connections to the same server. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1540 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
bd7cc25590
commit
7773aabb2c
@ -9,6 +9,7 @@ int proxy_port;
|
|||||||
char *proxy_string, *proxy_password;
|
char *proxy_string, *proxy_password;
|
||||||
|
|
||||||
unsigned short family; /* 0 = don't care, AF_INET or AF_INET6 */
|
unsigned short family; /* 0 = don't care, AF_INET or AF_INET6 */
|
||||||
|
char *tag; /* try to keep this tag when connected to server */
|
||||||
char *address;
|
char *address;
|
||||||
int port;
|
int port;
|
||||||
char *chatnet;
|
char *chatnet;
|
||||||
|
@ -37,6 +37,9 @@ static int reconnect_time;
|
|||||||
|
|
||||||
void reconnect_save_status(SERVER_CONNECT_REC *conn, SERVER_REC *server)
|
void reconnect_save_status(SERVER_CONNECT_REC *conn, SERVER_REC *server)
|
||||||
{
|
{
|
||||||
|
g_free_not_null(conn->tag);
|
||||||
|
conn->tag = g_strdup(server->tag);
|
||||||
|
|
||||||
g_free_not_null(conn->away_reason);
|
g_free_not_null(conn->away_reason);
|
||||||
conn->away_reason = !server->usermode_away ? NULL :
|
conn->away_reason = !server->usermode_away ? NULL :
|
||||||
g_strdup(server->away_reason);
|
g_strdup(server->away_reason);
|
||||||
@ -133,6 +136,8 @@ server_connect_copy_skeleton(SERVER_CONNECT_REC *src, int connect_info)
|
|||||||
dest->proxy_string = g_strdup(src->proxy_string);
|
dest->proxy_string = g_strdup(src->proxy_string);
|
||||||
dest->proxy_password = g_strdup(src->proxy_password);
|
dest->proxy_password = g_strdup(src->proxy_password);
|
||||||
|
|
||||||
|
dest->tag = g_strdup(src->tag);
|
||||||
|
|
||||||
if (connect_info) {
|
if (connect_info) {
|
||||||
dest->family = src->family;
|
dest->family = src->family;
|
||||||
dest->address = g_strdup(src->address);
|
dest->address = g_strdup(src->address);
|
||||||
@ -224,7 +229,7 @@ static void sig_reconnect(SERVER_REC *server)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* always try to first connect to the first on the list where we
|
/* always try to first connect to the first on the list where we
|
||||||
haven't got unsuccessful connection attempts for the last half
|
haven't got unsuccessful connection attempts for the past half
|
||||||
an hour. */
|
an hour. */
|
||||||
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
@ -385,13 +390,11 @@ static void cmd_reconnect(const char *data, SERVER_REC *server)
|
|||||||
static void cmd_disconnect(const char *data, SERVER_REC *server)
|
static void cmd_disconnect(const char *data, SERVER_REC *server)
|
||||||
{
|
{
|
||||||
RECONNECT_REC *rec;
|
RECONNECT_REC *rec;
|
||||||
int tag;
|
|
||||||
|
|
||||||
if (g_strncasecmp(data, "RECON-", 6) != 0)
|
if (g_strncasecmp(data, "RECON-", 6) != 0)
|
||||||
return; /* handle only reconnection removing */
|
return; /* handle only reconnection removing */
|
||||||
|
|
||||||
rec = sscanf(data+6, "%d", &tag) == 1 && tag > 0 ?
|
rec = reconnect_find_tag(atoi(data+6));
|
||||||
reconnect_find_tag(tag) : NULL;
|
|
||||||
|
|
||||||
if (rec == NULL)
|
if (rec == NULL)
|
||||||
signal_emit("server reconnect not found", 1, data);
|
signal_emit("server reconnect not found", 1, data);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#define FAILED_RECONNECT_WAIT (60*30)
|
#define FAILED_RECONNECT_WAIT (60*30)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int tag;
|
int tag;
|
||||||
time_t next_connect;
|
time_t next_connect;
|
||||||
|
|
||||||
SERVER_CONNECT_REC *conn;
|
SERVER_CONNECT_REC *conn;
|
||||||
|
@ -101,12 +101,23 @@ static char *server_create_tag(SERVER_CONNECT_REC *conn)
|
|||||||
char *tag;
|
char *tag;
|
||||||
int num;
|
int num;
|
||||||
|
|
||||||
g_return_val_if_fail(IS_SERVER_CONNECT(conn), NULL);
|
g_return_val_if_fail(IS_SERVER_CONNECT(conn), NULL);
|
||||||
|
|
||||||
tag = conn->chatnet != NULL && *conn->chatnet != '\0' ?
|
tag = conn->chatnet != NULL && *conn->chatnet != '\0' ?
|
||||||
g_strdup(conn->chatnet) :
|
g_strdup(conn->chatnet) :
|
||||||
server_create_address_tag(conn->address);
|
server_create_address_tag(conn->address);
|
||||||
|
|
||||||
|
if (conn->tag != NULL && server_find_tag(conn->tag) == NULL &&
|
||||||
|
strncmp(conn->tag, tag, strlen(tag)) == 0) {
|
||||||
|
/* use the existing tag if it begins with the same ID -
|
||||||
|
this is useful when you have several connections to
|
||||||
|
same server and you want to keep the same tags with
|
||||||
|
the servers (or it would cause problems when rejoining
|
||||||
|
/LAYOUT SAVEd channels). */
|
||||||
|
return g_strdup(conn->tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* then just append numbers after tag until unused is found.. */
|
/* then just append numbers after tag until unused is found.. */
|
||||||
str = g_string_new(tag);
|
str = g_string_new(tag);
|
||||||
for (num = 2; server_find_tag(str->str) != NULL; num++)
|
for (num = 2; server_find_tag(str->str) != NULL; num++)
|
||||||
@ -410,6 +421,7 @@ void server_connect_free(SERVER_CONNECT_REC *conn)
|
|||||||
g_free_not_null(conn->proxy_string);
|
g_free_not_null(conn->proxy_string);
|
||||||
g_free_not_null(conn->proxy_password);
|
g_free_not_null(conn->proxy_password);
|
||||||
|
|
||||||
|
g_free_not_null(conn->tag);
|
||||||
g_free_not_null(conn->address);
|
g_free_not_null(conn->address);
|
||||||
g_free_not_null(conn->chatnet);
|
g_free_not_null(conn->chatnet);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user