<!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][16683] </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=16683">16683</a></dd>
<dt>Author</dt> <dd>mrene</dd>
<dt>Date</dt> <dd>2010-02-17 16:36:07 -0600 (Wed, 17 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>rename switch_socket_create_pollfd to switch_socket_create_pollset, add switch_socket_create_pollfd that really creates a pollfd out of a socket, expose switch_pollset_poll and switch_pollset_remove</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcincludeswitch_aprh">freeswitch/trunk/src/include/switch_apr.h</a></li>
<li><a href="#freeswitchtrunksrcswitch_aprc">freeswitch/trunk/src/switch_apr.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_rtpc">freeswitch/trunk/src/switch_rtp.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcincludeswitch_aprh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_apr.h (16682 => 16683)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_apr.h        2010-02-17 22:00:01 UTC (rev 16682)
+++ freeswitch/trunk/src/include/switch_apr.h        2010-02-17 22:36:07 UTC (rev 16683)
</span><span class="lines">@@ -1297,6 +1297,22 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_pollset_add(switch_pollset_t *pollset, const switch_pollfd_t *descriptor);
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * Remove a descriptor from a pollset
+ * @param pollset The pollset from which to remove the descriptor
+ * @param descriptor The descriptor to remove
+ * @remark If the pollset has been created with APR_POLLSET_THREADSAFE
+ *         and thread T1 is blocked in a call to apr_pollset_poll() for
+ *         this same pollset that is being modified via apr_pollset_remove()
+ *         in thread T2, the currently executing apr_pollset_poll() call in
+ *         T1 will either: (1) automatically exclude the newly added descriptor
+ *         in the set of descriptors it is watching or (2) return immediately
+ *         with APR_EINTR.  Option (1) is recommended, but option (2) is
+ *         allowed for implementations where option (1) is impossible
+ *         or impractical.
+ */
+SWITCH_DECLARE(switch_status_t) switch_pollset_remove(switch_pollset_t *pollset, const switch_pollfd_t *descriptor);
+
+/**
</ins><span class="cx">  * Poll the sockets in the poll structure
</span><span class="cx">  * @param aprset The poll structure we will be using. 
</span><span class="cx">  * @param numsock The number of sockets we are polling
</span><span class="lines">@@ -1311,16 +1327,35 @@
</span><span class="cx">  */
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset, int32_t numsock, int32_t *nsds, switch_interval_time_t timeout);
</span><span class="cx"> 
</span><ins>+/**
+ * Block for activity on the descriptor(s) in a pollset
+ * @param pollset The pollset to use
+ * @param timeout Timeout in microseconds
+ * @param num Number of signalled descriptors (output parameter)
+ * @param descriptors Array of signalled descriptors (output parameter)
+ */
+SWITCH_DECLARE(switch_status_t) switch_pollset_poll(switch_pollset_t *pollset, switch_interval_time_t timeout, int32_t *num, const switch_pollfd_t **descriptors);
+
</ins><span class="cx"> /*!
</span><del>-  \brief Create a set of file descriptors to poll
</del><ins>+  \brief Create a set of file descriptors to poll from a socket
</ins><span class="cx">   \param poll the polfd to create
</span><span class="cx">   \param sock the socket to add
</span><span class="cx">   \param flags the flags to modify the behaviour
</span><span class="cx">   \param pool the memory pool to use
</span><span class="cx">   \return SWITCH_STATUS_SUCCESS when successful
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t ** poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_socket_create_pollset(switch_pollfd_t ** poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool);
</ins><span class="cx"> 
</span><ins>+/*!
+  \brief Create a pollfd out of a socket
+  \param poll the polfd to create
+  \param sock the socket to add
+  \param flags the flags to modify the behaviour
+  \param client_data custom user data
+  \param pool the memory pool to use
+  \return SWITCH_STATUS_SUCCESS when successful
+*/
+SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **pollfd, switch_socket_t *sock, int16_t flags, void *client_data, switch_memory_pool_t *pool);
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_array_header_t ** result, switch_memory_pool_t *p);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t ** sa, switch_bool_t remote, switch_socket_t *sock);
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_aprc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_apr.c (16682 => 16683)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_apr.c        2010-02-17 22:00:01 UTC (rev 16682)
+++ freeswitch/trunk/src/switch_apr.c        2010-02-17 22:36:07 UTC (rev 16683)
</span><span class="lines">@@ -821,13 +821,58 @@
</span><span class="cx"> 
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_pollset_add(switch_pollset_t *pollset, const switch_pollfd_t *descriptor)
</span><span class="cx"> {
</span><del>-        if (!pollset) {
</del><ins>+        if (!pollset || !descriptor) {
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return apr_pollset_add((apr_pollset_t *) pollset, (const apr_pollfd_t *) descriptor);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+SWITCH_DECLARE(switch_status_t) switch_pollset_remove(switch_pollset_t *pollset, const switch_pollfd_t *descriptor)
+{
+        if (!pollset || !descriptor) {
+                return SWITCH_STATUS_FALSE;
+        }        
+        
+        return apr_pollset_remove((apr_pollset_t *) pollset, (const apr_pollfd_t *) descriptor);
+}
+
+SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **pollfd, switch_socket_t *sock, int16_t flags, void *client_data, switch_memory_pool_t *pool)
+{
+        if (!pollfd || !sock) {
+                return SWITCH_STATUS_FALSE;
+        }
+        
+        if ((*pollfd = (switch_pollfd_t*)apr_palloc(pool, sizeof(switch_pollfd_t))) == 0) {
+                return SWITCH_STATUS_MEMERR;
+        }
+        
+        memset(*pollfd, 0, sizeof(switch_pollfd_t));
+
+        (*pollfd)-&gt;desc_type = APR_POLL_SOCKET;
+        (*pollfd)-&gt;reqevents = flags;
+        (*pollfd)-&gt;desc.s = sock;
+        (*pollfd)-&gt;client_data = client_data;
+        
+        return SWITCH_STATUS_SUCCESS;
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_pollset_poll(switch_pollset_t *pollset, switch_interval_time_t timeout, int32_t *num, const switch_pollfd_t **descriptors)
+{
+        apr_status_t st = SWITCH_STATUS_FALSE;
+        
+        if (pollset) {
+                st = apr_pollset_poll((apr_pollset_t *) pollset, timeout, num, (const apr_pollfd_t **) descriptors);
+                
+                if (st == APR_TIMEUP) {
+                        st = SWITCH_STATUS_TIMEOUT;
+                }
+        }
+        
+        return st;
+}
+
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset, int32_t numsock, int32_t *nsds, switch_interval_time_t timeout)
</span><span class="cx"> {
</span><span class="cx">         apr_status_t st = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -843,28 +888,18 @@
</span><span class="cx">         return st;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t ** poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_socket_create_pollset(switch_pollfd_t ** poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         switch_pollset_t *pollset;
</span><span class="cx"> 
</span><del>-        void *ptr = NULL;
-
-        if ((ptr = apr_palloc(pool, sizeof(switch_pollfd_t))) == 0) {
-                return SWITCH_STATUS_MEMERR;
</del><ins>+        if (switch_pollset_create(&amp;pollset, 1, pool, 0) != SWITCH_STATUS_SUCCESS) {
+                return SWITCH_STATUS_GENERR;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-        if (switch_pollset_create(&amp;pollset, 1, pool, 0) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_socket_create_pollfd(poll, sock, flags, sock, pool) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        memset(ptr, 0, sizeof(switch_pollfd_t));
-        *poll = ptr;
-
-        (*poll)-&gt;desc_type = APR_POLL_SOCKET;
-        (*poll)-&gt;reqevents = flags;
-        (*poll)-&gt;desc.s = sock;
-        (*poll)-&gt;client_data = sock;
-
</del><span class="cx">         if (switch_pollset_add(pollset, *poll) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_rtpc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_rtp.c (16682 => 16683)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_rtp.c        2010-02-17 22:00:01 UTC (rev 16682)
+++ freeswitch/trunk/src/switch_rtp.c        2010-02-17 22:36:07 UTC (rev 16683)
</span><span class="lines">@@ -837,7 +837,7 @@
</span><span class="cx">                 switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        switch_socket_create_pollfd(&amp;rtp_session-&gt;read_pollfd, rtp_session-&gt;sock_input, SWITCH_POLLIN | SWITCH_POLLERR, rtp_session-&gt;pool);
</del><ins>+        switch_socket_create_pollset(&amp;rtp_session-&gt;read_pollfd, rtp_session-&gt;sock_input, SWITCH_POLLIN | SWITCH_POLLERR, rtp_session-&gt;pool);
</ins><span class="cx"> 
</span><span class="cx">         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         *err = &quot;Success&quot;;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>