<div dir="ltr"><div>humm,<br><br></div><div>When datagram server is initialized in method "mi_init_datagram_server", it set tx_sock equal to rx_sock, instead of creating a new reply socket. So that when an async command is received in method "mi_datagram_server" with tx_sock reference, i pass it to "build_async_handler" method which is then stored to a newly added parameter to "my_address_socket" structure (see the last 5 lines of this method). This same structure is passed and used to send reply in "datagram_close_async" method, so i just used the existing socket reference stored in structure to send the reply, instead of creating new one.<br>

<br></div><div>So basically original socket reference is preserved for reply, instead of creating new. Shouldn't this work for async process or i am missing something here?<br></div><div><br></div><div>Thank you.<br>
</div>
<div><br><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Mar 28, 2014 at 11:28 PM, Daniel-Constantin Mierla <span dir="ltr"><<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Have you tested with async mi commands? The function
    build_async_handler() is cloning the information in shared memory,
    expecting that the response to the mi command to be done from
    another process. In that case, the socket is no longer valid,
    because it was created only in the mi process.<br>
    <br>
    I haven't analyzed deeply, but it is very likely to be what I said
    above.<br>
    <br>
    Options coming in my mind:<br>
    <br>
    - for async case keep the old way of creating a new socket. This can
    be propagated by setting field tx_sock=0<br>
    - try to bind to same socket in async handler, provided the initial
    socket is created with resuse addr/port<br>
    <br>
    Cheers,<br>
    Daniel<div><div class="h5"><br>
    <br>
    <div>On 28/03/14 21:49, Muhammad Shahzad
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">Please find attached updated patch as requested.<br>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Fri, Mar 28, 2014 at 8:49 PM,
          Daniel-Constantin Mierla <span dir="ltr"><<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>></span> wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for
            the patch. Can you resend it without commented code? Just
            remove the lines that are no longer used, to have clean
            code.<br>
            <br>
            Cheers,<br>
            Daniel
            <div>
              <div><br>
                <br>
                On 28/03/14 01:29, Muhammad Shahzad wrote:<br>
                <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  Hi,<br>
                  <br>
                  After wasting most of the day trying to make
                  mi_datagram over UDP socket work. I eventually realize
                  that it does asymmetric UDP communication, which
                  creates a lot of trouble for writing a useful MI
                  script using PERL or Python etc.<br>
                  <br>
                  Anyhow, i go through the module code and was able to
                  write a patch for symmetric UDP communication using
                  mi_datagram.<br>
                  <br>
                  I have tested the patch using both Kamailio 4.1 and
                  trunk branches and it seems to compile and run
                  flawlessly.<br>
                  <br>
                  I am attaching here with this patch for Kamailio
                  community. It would be great if Kamailio developers
                  would review and commit this patch to source trunk.<br>
                  <br>
                  Thank you.<br>
                  <br>
                  <br>
                </blockquote>
                <br>
              </div>
            </div>
            <span><font color="#888888">
                -- <br>
                Daniel-Constantin Mierla - <a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a><br>
                <a href="http://twitter.com/#%21/miconda" target="_blank">http://twitter.com/#!/miconda</a>
                - <a href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a><br>
                Kamailio World Conference - April 2-4, 2014, Berlin,
                Germany<br>
                <a href="http://www.kamailioworld.com" target="_blank">http://www.kamailioworld.com</a><br>
                <br>
              </font></span></blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <pre cols="72">-- 
Daniel-Constantin Mierla - <a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
<a href="http://twitter.com/#!/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a>
Kamailio World Conference - April 2-4, 2014, Berlin, Germany
<a href="http://www.kamailioworld.com" target="_blank">http://www.kamailioworld.com</a></pre>
  </div></div></div>

</blockquote></div><br></div>