<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][14410] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=14410">14410</a></dd>
<dt>Author</dt> <dd>gmaruzz</dd>
<dt>Date</dt> <dd>2009-07-29 04:08:31 -0500 (Wed, 29 Jul 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>skypiax: patch from Seven Du for hunting IDLE channels in a round-robin way (RR interface vs ANY interface). patch from Seven Du for removing interface as #'interface_id' and #'interface_name'. gmaruzz (meh) patch interface_remove() not to alter the global 'running' variable (it would cause all running signaling and API thread to exit) but to use a newly added tech_pvt-&gt;running variable. Also, changed behavior of interface_exists() for correct identification when using #interface_name and #interface_id. PLEASE TEST IT HEAVILY</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxmod_skypiaxc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxskypiaxh">freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxskypiax_protocolc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxmod_skypiaxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (14409 => 14410)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2009-07-29 08:32:20 UTC (rev 14409)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2009-07-29 09:08:31 UTC (rev 14410)
</span><span class="lines">@@ -86,7 +86,7 @@
</span><span class="cx"> SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL);
</span><span class="cx"> SWITCH_STANDARD_API(sk_function);
</span><span class="cx"> /* BEGIN: Changes here */
</span><del>-#define SK_SYNTAX &quot;list || reload || console || remove interface_name || skype_API_msg&quot;
</del><ins>+#define SK_SYNTAX &quot;list [full] || console || skype_API_msg || remove &lt;skypeusername | #interface_name | #interface_id&gt; || reload&quot;
</ins><span class="cx"> /* END: Changes heres */
</span><span class="cx"> SWITCH_STANDARD_API(skypiax_function);
</span><span class="cx"> #define SKYPIAX_SYNTAX &quot;interface_name skype_API_msg&quot;
</span><span class="lines">@@ -111,7 +111,9 @@
</span><span class="cx">   int codec_rates_last;
</span><span class="cx">   unsigned int flags;
</span><span class="cx">   int fd;
</span><del>-  int calls;
</del><ins>+  int calls;          
+  int real_interfaces;
+  int next_interface;
</ins><span class="cx">   char hold_music[256];
</span><span class="cx">   private_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
</span><span class="cx">   switch_mutex_t *mutex;
</span><span class="lines">@@ -211,20 +213,45 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> /* BEGIN: Changes here */
</span><del>-static switch_status_t interface_exists(char *skype_user)
</del><ins>+static switch_status_t interface_exists(char *interface)
</ins><span class="cx"> {
</span><span class="cx">   int i;
</span><ins>+  int interface_id;
+
+  if ( *interface == '#') { /* look by interface id or interface name */
+    interface++;
+    switch_assert(interface);
+    interface_id = atoi(interface);
+
+      /* take a number as interface id */
+    if ( interface_id &gt; 0 || (interface_id == 0 &amp;&amp; strcmp(interface, &quot;0&quot;) == 0 )) {
+        if (strlen(globals.SKYPIAX_INTERFACES[interface_id].name)) {
+          return SWITCH_STATUS_SUCCESS;
+        }
+    } else {
+
+      for (interface_id = 0; interface_id &lt; SKYPIAX_MAX_INTERFACES; interface_id++) {
+        if (strcmp(globals.SKYPIAX_INTERFACES[interface_id].name, interface) == 0) {
+          return SWITCH_STATUS_SUCCESS;
+          break;
+        }
+      }
+    }
+  } else { /* look by skype_user */
+
+
</ins><span class="cx">   for (i = 0; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
</span><span class="cx">     if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
</span><del>-      if (strcmp(globals.SKYPIAX_INTERFACES[i].skype_user, skype_user) == 0) {
</del><ins>+      if (strcmp(globals.SKYPIAX_INTERFACES[i].name, interface) == 0) {
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">       }
</span><span class="cx">     }
</span><span class="cx">   }
</span><ins>+  }
</ins><span class="cx">   return SWITCH_STATUS_FALSE;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static switch_status_t remove_interface(char *skype_user)
</del><ins>+static switch_status_t remove_interface(char *interface)
</ins><span class="cx"> {
</span><span class="cx">   int x = 100;
</span><span class="cx">   unsigned int howmany = 8;
</span><span class="lines">@@ -232,26 +259,48 @@
</span><span class="cx">   private_t *tech_pvt = NULL;
</span><span class="cx">   switch_status_t status;
</span><span class="cx"> 
</span><del>-  running = 0;
</del><ins>+  //running = 0;
</ins><span class="cx"> 
</span><del>-  for (interface_id = 0; interface_id &lt; SKYPIAX_MAX_INTERFACES; interface_id++) {
-    if (strcmp(globals.SKYPIAX_INTERFACES[interface_id].skype_user, skype_user) == 0) {
</del><ins>+
+  if ( *interface == '#') { /* remove by interface id or interface name */
+    interface++;
+    switch_assert(interface);
+    interface_id = atoi(interface);
+
+    if ( interface_id &gt; 0 || (interface_id == 0 &amp;&amp; strcmp(interface, &quot;0&quot;) == 0 )) {
+      /* take a number as interface id */
</ins><span class="cx">       tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
</span><del>-      break;
</del><ins>+    } else {
+
+      for (interface_id = 0; interface_id &lt; SKYPIAX_MAX_INTERFACES; interface_id++) {
+        if (strcmp(globals.SKYPIAX_INTERFACES[interface_id].name, interface) == 0) {
+          tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
+          break;
+        }
+      }
</ins><span class="cx">     }
</span><ins>+  } else { /* remove by skype_user */
+    for (interface_id = 0; interface_id &lt; SKYPIAX_MAX_INTERFACES; interface_id++) {
+      if (strcmp(globals.SKYPIAX_INTERFACES[interface_id].skype_user, interface) == 0) {
+        tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
+        break;
+      }
+    }
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   if (!tech_pvt) {
</span><del>-    DEBUGA_SKYPE(&quot;interface for skype user '%s' does not exist\n&quot;, SKYPIAX_P_LOG,
-                 skype_user);
</del><ins>+    DEBUGA_SKYPE(&quot;interface '%s' does not exist\n&quot;, SKYPIAX_P_LOG,
+                 interface);
</ins><span class="cx">     goto end;
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   if (strlen(globals.SKYPIAX_INTERFACES[interface_id].session_uuid_str)) {
</span><del>-    DEBUGA_SKYPE(&quot;interface for skype user '%s' is busy\n&quot;, SKYPIAX_P_LOG, skype_user);
</del><ins>+    DEBUGA_SKYPE(&quot;interface '%s' is busy\n&quot;, SKYPIAX_P_LOG, interface);
</ins><span class="cx">     goto end;
</span><span class="cx">   }
</span><span class="cx"> 
</span><ins>+  globals.SKYPIAX_INTERFACES[interface_id].running=0;
+
</ins><span class="cx">   if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
</span><span class="cx"> #ifdef WIN32
</span><span class="cx">     switch_file_write(tech_pvt-&gt;SkypiaxHandles.fdesc[1], &quot;sciutati&quot;, &amp;howmany); // let's the controldev_thread die
</span><span class="lines">@@ -300,10 +349,16 @@
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   memset(&amp;globals.SKYPIAX_INTERFACES[interface_id], '\0', sizeof(private_t));
</span><del>-  DEBUGA_SKYPE(&quot;interface for skype user '%s' deleted successfully\n&quot;, SKYPIAX_P_LOG,
-               skype_user);
</del><ins>+
+  switch_mutex_lock(globals.mutex);
+  globals.real_interfaces--;
+  switch_mutex_unlock(globals.mutex);
+
+  DEBUGA_SKYPE(&quot;interface '%s' deleted successfully\n&quot;, SKYPIAX_P_LOG,
+               interface);
+  globals.SKYPIAX_INTERFACES[interface_id].running=1;
</ins><span class="cx"> end:
</span><del>-  running = 1;
</del><ins>+  //running = 1;
</ins><span class="cx">   return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -333,6 +388,7 @@
</span><span class="cx">   switch_channel_set_state(channel, CS_ROUTING);
</span><span class="cx">   switch_mutex_lock(globals.mutex);
</span><span class="cx">   globals.calls++;
</span><ins>+
</ins><span class="cx">   switch_mutex_unlock(globals.mutex);
</span><span class="cx"> 
</span><span class="cx">   DEBUGA_SKYPE(&quot;%s CHANNEL INIT\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</span><span class="lines">@@ -716,9 +772,14 @@
</span><span class="cx">           /* we've been asked for the &quot;ANY&quot; interface, let's find the first idle interface */
</span><span class="cx">           DEBUGA_SKYPE(&quot;Finding one available skype interface\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">           tech_pvt = find_available_skypiax_interface(NULL);
</span><del>-          if (tech_pvt)
-            found = 1;
</del><ins>+          if (tech_pvt) found = 1;
+        } else if(strncmp(&quot;RR&quot;, interface_name, strlen(interface_name)) == 0) {
+          /* Find the first idle interface using Round Robin */
+          DEBUGA_SKYPE(&quot;Finding one available skype interface RR\n&quot;, SKYPIAX_P_LOG);
+          tech_pvt = find_available_skypiax_interface_rr();
+          if (tech_pvt) found = 1;
</ins><span class="cx">         }
</span><ins>+
</ins><span class="cx">         for (i = 0; !found &amp;&amp; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
</span><span class="cx">           /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the &quot;ANY&quot; interface */
</span><span class="cx">           if (strlen(globals.SKYPIAX_INTERFACES[i].name)
</span><span class="lines">@@ -815,7 +876,7 @@
</span><span class="cx">                (void *) tech_pvt);
</span><span class="cx"> 
</span><span class="cx">   while (forever) {
</span><del>-    if (!running)
</del><ins>+    if (!(running &amp;&amp; tech_pvt-&gt;running))
</ins><span class="cx">       break;
</span><span class="cx">     res = skypiax_signaling_read(tech_pvt);
</span><span class="cx">     if (res == CALLFLOW_INCOMING_HANGUP) {
</span><span class="lines">@@ -983,7 +1044,7 @@
</span><span class="cx"> 
</span><span class="cx">       /* BEGIN: Changes here */
</span><span class="cx">       if (reload_type == SOFT_RELOAD) {
</span><del>-        if (interface_exists(skype_user) == SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (interface_exists(name) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">           continue;
</span><span class="cx">         }
</span><span class="cx">       }
</span><span class="lines">@@ -1049,7 +1110,9 @@
</span><span class="cx"> 
</span><span class="cx">         memset(&amp;newconf, '\0', sizeof(newconf));
</span><span class="cx">         globals.SKYPIAX_INTERFACES[interface_id] = newconf;
</span><ins>+                globals.SKYPIAX_INTERFACES[interface_id].running = 1;
</ins><span class="cx"> 
</span><ins>+
</ins><span class="cx">         tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
</span><span class="cx"> 
</span><span class="cx">         switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].interface_id, id);
</span><span class="lines">@@ -1189,6 +1252,9 @@
</span><span class="cx"> 
</span><span class="cx">     for (i = 0; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
</span><span class="cx">       if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
</span><ins>+               /* How many real intterfaces */
+               globals.real_interfaces = i + 1;
+
</ins><span class="cx">         tech_pvt = &amp;globals.SKYPIAX_INTERFACES[i];
</span><span class="cx"> 
</span><span class="cx">         DEBUGA_SKYPE(&quot;i=%d globals.SKYPIAX_INTERFACES[%d].interface_id=%s\n&quot;,
</span><span class="lines">@@ -1550,7 +1616,49 @@
</span><span class="cx">   else
</span><span class="cx">     return NULL;
</span><span class="cx"> }
</span><ins>+   
+private_t *find_available_skypiax_interface_rr(void)
+{
+  private_t *tech_pvt = NULL;
+  int i;
+  /* int num_interfaces = SKYPIAX_MAX_INTERFACES; */
+  int num_interfaces = globals.real_interfaces;
</ins><span class="cx"> 
</span><ins>+  switch_mutex_lock(globals.mutex);
+
+  /* Fact is the real interface start from 1 */
+  if (globals.next_interface == 0) globals.next_interface = 1;
+
+  for (i = 0; i &lt; num_interfaces; i++) { 
+    int interface_id;
+
+    interface_id = globals.next_interface + i;
+    interface_id = interface_id &lt; num_interfaces ? interface_id : interface_id - num_interfaces + 1;
+
+    if (strlen(globals.SKYPIAX_INTERFACES[interface_id].name)) {
+      int skype_state = 0;
+
+      tech_pvt = &amp;globals.SKYPIAX_INTERFACES[interface_id];
+      skype_state = tech_pvt-&gt;interface_state;
+      DEBUGA_SKYPE(&quot;skype interface: %d, name: %s, state: %d\n&quot;, SKYPIAX_P_LOG, interface_id,
+                         globals.SKYPIAX_INTERFACES[interface_id].name, skype_state);
+      if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) {
+        /*set to Dialing state to avoid other thread fint it, don't know if it is safe */
+        tech_pvt-&gt;interface_state = SKYPIAX_STATE_DIALING ;
+        
+        globals.next_interface = interface_id + 1 &lt; num_interfaces ? interface_id + 1 : 1;
+        switch_mutex_unlock(globals.mutex);
+        return tech_pvt;
+      }
+    } else {
+      DEBUGA_SKYPE(&quot;Skype interface: %d blank!! A hole here means we cannot hunt the last interface.\n&quot;, SKYPIAX_P_LOG, interface_id);
+    }
+  }
+
+  switch_mutex_unlock(globals.mutex);
+  return NULL;
+}
+
</ins><span class="cx"> SWITCH_STANDARD_API(sk_function)
</span><span class="cx"> {
</span><span class="cx">   char *mycmd = NULL, *argv[10] = { 0 };
</span><span class="lines">@@ -1571,21 +1679,32 @@
</span><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">   if (!strcasecmp(argv[0], &quot;list&quot;)) {
</span><del>-    int i;
</del><ins>+    int i;             
+       char next_flag_char = ' ';
+
</ins><span class="cx">     for (i = 0; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
</span><ins>+         next_flag_char = i == globals.next_interface ? '*' : ' ';
+
</ins><span class="cx">       if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
</span><span class="cx">         if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)) {
</span><span class="cx">           stream-&gt;write_function(stream,
</span><del>-                                 &quot;globals.SKYPIAX_INTERFACES[%d].name=\t|||%s||| is \tBUSY, session_uuid_str=|||%s|||\n&quot;,
</del><ins>+                                 &quot;%c\t%d\t[%s]\tBUSY, session_uuid_str=|||%s|||\n&quot;,
+                                 next_flag_char,
</ins><span class="cx">                                  i, globals.SKYPIAX_INTERFACES[i].name,
</span><span class="cx">                                  globals.SKYPIAX_INTERFACES[i].session_uuid_str);
</span><span class="cx">         } else {
</span><span class="cx">           stream-&gt;write_function(stream,
</span><del>-                                 &quot;globals.SKYPIAX_INTERFACES[%d].name=\t|||%s||| is \tIDLE\n&quot;,
</del><ins>+                                 &quot;%c\t%d\t[%s]\tIDLE\n&quot;,
+                                 next_flag_char,
</ins><span class="cx">                                  i, globals.SKYPIAX_INTERFACES[i].name);
</span><span class="cx">         }
</span><del>-      }
</del><ins>+      } else if(argc &gt; 1 &amp;&amp; !strcasecmp(argv[1], &quot;full&quot;)) {
+        stream-&gt;write_function(stream, &quot;%c\t%d\n&quot;, next_flag_char, i);
+      }                                                                      
+
</ins><span class="cx">     }
</span><ins>+    stream-&gt;write_function(stream, &quot;\nTotal: %d\n&quot;, globals.real_interfaces - 1 );
+
</ins><span class="cx">   } else if (!strcasecmp(argv[0], &quot;console&quot;)) {
</span><span class="cx">     int i;
</span><span class="cx">     int found = 0;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxskypiaxh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h (14409 => 14410)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h        2009-07-29 08:32:20 UTC (rev 14409)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h        2009-07-29 09:08:31 UTC (rev 14410)
</span><span class="lines">@@ -238,6 +238,7 @@
</span><span class="cx">   struct timeval transfer_time;
</span><span class="cx">   char transfer_callid_number[50];
</span><span class="cx">   char skype_transfer_call_id[512];
</span><ins>+  int running;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> typedef struct private_object private_t;
</span><span class="lines">@@ -276,6 +277,7 @@
</span><span class="cx"> #endif /* WIN32 */
</span><span class="cx"> int skypiax_close_socket(unsigned int fd);
</span><span class="cx"> private_t *find_available_skypiax_interface(private_t * tech_pvt);
</span><ins>+private_t *find_available_skypiax_interface_rr(void);
</ins><span class="cx"> int remote_party_is_ringing(private_t * tech_pvt);
</span><span class="cx"> int remote_party_is_early_media(private_t * tech_pvt);
</span><span class="cx"> int skypiax_answer(private_t * tech_pvt, char *id, char *value);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxskypiax_protocolc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (14409 => 14410)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2009-07-29 08:32:20 UTC (rev 14409)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2009-07-29 09:08:31 UTC (rev 14410)
</span><span class="lines">@@ -489,7 +489,7 @@
</span><span class="cx">     fd_set fsgio;
</span><span class="cx">     struct timeval togio;
</span><span class="cx"> 
</span><del>-    if (!running)
</del><ins>+    if (!(running &amp;&amp; tech_pvt-&gt;running))
</ins><span class="cx">       break;
</span><span class="cx">     FD_ZERO(&amp;fsgio);
</span><span class="cx">     togio.tv_usec = 20000;      //20msec
</span><span class="lines">@@ -506,7 +506,7 @@
</span><span class="cx">       while ((fd = accept(s, (struct sockaddr *) &amp;remote_addr, &amp;sin_size)) &gt; 0) {
</span><span class="cx">         DEBUGA_SKYPE(&quot;ACCEPTED here I send you %d\n&quot;, SKYPIAX_P_LOG,
</span><span class="cx">                      tech_pvt-&gt;tcp_srv_port);
</span><del>-        if (!running)
</del><ins>+        if (!(running &amp;&amp; tech_pvt-&gt;running))
</ins><span class="cx">           break;
</span><span class="cx">         while (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN
</span><span class="cx">                &amp;&amp; (tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_INPROGRESS
</span><span class="lines">@@ -519,7 +519,7 @@
</span><span class="cx">           fd_set fs;
</span><span class="cx">           struct timeval to;
</span><span class="cx"> 
</span><del>-          if (!running)
</del><ins>+          if (!(running &amp;&amp; tech_pvt-&gt;running))
</ins><span class="cx">             break;
</span><span class="cx">           //exit = 1;
</span><span class="cx"> 
</span><span class="lines">@@ -677,7 +677,7 @@
</span><span class="cx">     fd_set fsgio;
</span><span class="cx">     struct timeval togio;
</span><span class="cx"> 
</span><del>-    if (!running)
</del><ins>+    if (!(running &amp;&amp; tech_pvt-&gt;running))
</ins><span class="cx">       break;
</span><span class="cx">     FD_ZERO(&amp;fsgio);
</span><span class="cx">     togio.tv_usec = 20000;      //20msec
</span><span class="lines">@@ -698,7 +698,7 @@
</span><span class="cx">         fcntl(tech_pvt-&gt;audioskypepipe[0], F_SETFL, O_NONBLOCK);
</span><span class="cx"> #endif //WIN32
</span><span class="cx"> 
</span><del>-        if (!running)
</del><ins>+        if (!(running &amp;&amp; tech_pvt-&gt;running))
</ins><span class="cx">           break;
</span><span class="cx">         while (tech_pvt-&gt;interface_state != SKYPIAX_STATE_DOWN
</span><span class="cx">                &amp;&amp; (tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_INPROGRESS
</span><span class="lines">@@ -710,7 +710,7 @@
</span><span class="cx">           fd_set fs;
</span><span class="cx">           struct timeval to;
</span><span class="cx"> 
</span><del>-          if (!running)
</del><ins>+          if (!(running &amp;&amp; tech_pvt-&gt;running))
</ins><span class="cx">             break;
</span><span class="cx">           FD_ZERO(&amp;fs);
</span><span class="cx">           to.tv_usec = 120000;  //120msec
</span><span class="lines">@@ -1238,9 +1238,9 @@
</span><span class="cx">              (WPARAM) tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle, 0) != 0) {
</span><span class="cx">           tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle =
</span><span class="cx">             tech_pvt-&gt;SkypiaxHandles.win32_hInit_MainWindowHandle;
</span><del>-          while (running) {
</del><ins>+          while (running &amp;&amp; tech_pvt-&gt;running) {
</ins><span class="cx">             MSG oMessage;
</span><del>-            if (!running)
</del><ins>+            if (! (running &amp;&amp; tech_pvt-&gt;running))
</ins><span class="cx">               break;
</span><span class="cx">             while (GetMessage(&amp;oMessage, 0, 0, 0)) {
</span><span class="cx">               TranslateMessage(&amp;oMessage);
</span><span class="lines">@@ -1264,7 +1264,7 @@
</span><span class="cx">   private_t *tech_pvt = NULL;
</span><span class="cx"> 
</span><span class="cx">   xerror = err-&gt;error_code;
</span><del>-  ERRORA(&quot;Received error code %d from X Server\n\n&quot;, SKYPIAX_P_LOG, xerror);
</del><ins>+  ERRORA(&quot;Received error code %d from X Server\n\n&quot;, SKYPIAX_P_LOG, xerror); ///FIXME why crash the entire skypiax? just crash the interface, instead
</ins><span class="cx">   running = 0;
</span><span class="cx">   return 0;                     /*  ignore the error */
</span><span class="cx"> }
</span><span class="lines">@@ -1489,7 +1489,7 @@
</span><span class="cx"> 
</span><span class="cx">     while (1) {
</span><span class="cx">       XNextEvent(disp, &amp;an_event);
</span><del>-      if (!running)
</del><ins>+      if (! (running &amp;&amp; tech_pvt-&gt;running))
</ins><span class="cx">         break;
</span><span class="cx">       switch (an_event.type) {
</span><span class="cx">       case ClientMessage:
</span><span class="lines">@@ -1557,7 +1557,7 @@
</span><span class="cx">     running = 0;
</span><span class="cx">     return NULL;
</span><span class="cx">   }
</span><del>-  running = 0;
</del><ins>+  //running = 0;
</ins><span class="cx">   return NULL;
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>