pidgin: 5ca93c15: Fix a Zephyr crash and 10-second delay t...
rekkanoryo at pidgin.im
rekkanoryo at pidgin.im
Sat Dec 6 15:11:19 EST 2008
-----------------------------------------------------------------
Revision: 5ca93c156828361226abe779294044aa16d073c5
Ancestor: 9d6d2c0c693041ec877bc68b52e9df559a2d662a
Author: michael.terry at canonical.com
Date: 2008-12-06T19:31:21
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/5ca93c156828361226abe779294044aa16d073c5
Modified files:
COPYRIGHT libpurple/protocols/zephyr/zephyr.c
ChangeLog:
Fix a Zephyr crash and 10-second delay that can happen when you have an account
configured to use tzc but either tzc is installed or the configured tzc path is
invalid. Fixes #7700.
-------------- next part --------------
============================================================
--- COPYRIGHT 23930ad94f2508809f4db923b6a8ca3925738bc8
+++ COPYRIGHT 0601414f0c324a2997a3b0ca17572330e5baabbd
@@ -418,6 +418,7 @@ Philip Tellis
Brian Tarricone
Peter Teichman
Philip Tellis
+Michael Terry
Arun A. Tharuvai
Cestonaro Thilo
Will Thompson
============================================================
--- libpurple/protocols/zephyr/zephyr.c cc5a7c1fa6032d5d8b7d6c0919d2001423717c27
+++ libpurple/protocols/zephyr/zephyr.c ac38b979f642539a5a323c876ac9b44724bb7742
@@ -1607,27 +1607,21 @@ static void zephyr_login(PurpleAccount *
gboolean found_ps = FALSE;
gchar ** tzc_cmd_array = g_strsplit(purple_account_get_string(gc->account,"tzc_command","/usr/bin/tzc -e %s")," ",0);
if (close(1) == -1) {
- purple_debug_error("zephyr", "stdout couldn't be closed. dying\n");
exit(-1);
}
if (dup2(zephyr->fromtzc[1], 1) == -1) {
- purple_debug_error("zephyr", "dup2 of stdout failed \n");
exit(-1);
}
if (close(zephyr->fromtzc[1]) == -1) {
- purple_debug_error("zephyr", "closing of piped stdout failed\n");
exit(-1);
}
if (close(0) == -1) {
- purple_debug_error("zephyr", "stdin couldn't be closed. dying\n");
exit(-1);
}
if (dup2(zephyr->totzc[0], 0) == -1) {
- purple_debug_error("zephyr", "dup2 of stdin failed \n");
exit(-1);
}
if (close(zephyr->totzc[0]) == -1) {
- purple_debug_error("zephyr", "closing of piped stdin failed\n");
exit(-1);
}
/* tzc_command should really be of the form
@@ -1651,11 +1645,11 @@ static void zephyr_login(PurpleAccount *
}
if (!found_ps) {
- purple_connection_error(gc,"Tzc command needs %s to set the exposure\n");
- return;
+ exit(-1);
}
execvp(tzc_cmd_array[0], tzc_cmd_array);
+ exit(-1);
}
else {
fd_set rfds;
@@ -1667,6 +1661,7 @@ static void zephyr_login(PurpleAccount *
int parenlevel=0;
char* tempstr;
int tempstridx;
+ int select_status;
zephyr->tzc_pid = pid;
/* wait till we have data to read from ssh */
@@ -1678,11 +1673,19 @@ static void zephyr_login(PurpleAccount *
purple_debug_info("zephyr", "about to read from tzc\n");
- select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, NULL);
+ if (waitpid(pid, NULL, WNOHANG) == 0) { // Only select if tzc is still running
+ purple_debug_info("zephyr", "about to read from tzc\n");
+ select_status = select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, NULL);
+ }
+ else {
+ purple_debug_info("zephyr", "tzc exited early\n");
+ select_status = -1;
+ }
FD_ZERO(&rfds);
FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds);
- while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) {
+ while (select_status > 0 &&
+ select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv) > 0) {
read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1);
bufcur++;
if ((bufcur - buf) > (bufsize - 1)) {
More information about the Commits
mailing list