osip-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [osip-dev] Execution gets stuck at eXosip_event_wait


From: Aymeric Moizard
Subject: Re: [osip-dev] Execution gets stuck at eXosip_event_wait
Date: Tue, 12 Feb 2013 10:57:46 +0100

Hi Firman,

First, you must not "break" after the "EXOSIP_REGISTRATION_FAILURE". This will happen
usually before it succeed and is "normal operation" process. If you break, you will not
receive the next EXOSIP_REGISTRATION_SUCCESS event.


    }else if(evt->type == EXOSIP_REGISTRATION_FAILURE){
      fprintf(stderr, "Failure\n");
      //break;

Otherwise, I don't see any error in your code and according to me,
it should only wait in that method 50ms.

May be you can provide the backtrace and logs.
Regards
Aymeric

2013/2/12 Firman <address@hidden>
Hi Aymeric,
I followed your advice to run eXosip_event_wait in a loop but it seems that the execution stops right at that line of the code which calls eXosip_event_wait. Any advise as to what causes it? Thanks in advace.

#include <sys/socket.h>
#include <netinet/in.h>
#include <eXosip2/eXosip.h>

int registerClient(eXosip_t*);

int main(){

  // Initialize the osip trace (compile this code with -DENABLE_TRACE)
  eXosip_t *ctx;
  int i;
  int port = 5060;
  //TRACE_INITIALIZE(6, NULL);

  // Initialize eXosip (and osip) stack
  ctx = eXosip_malloc();
  if(ctx == NULL){
    return -1;
  }
  i = eXosip_init(ctx);
  if(i != 0){
    return -1;
  }

  eXosip_set_user_agent(ctx, "Firman");
  // Open a UDP socket for signalling
  i = eXosip_listen_addr(ctx, IPPROTO_UDP, NULL, port, AF_INET, 0);
  if(i!=0){
    eXosip_quit(ctx);
    fprintf (stderr, "could not initialize transport layer\n");
    return -1;
  }

  registerClient(ctx);

}

int registerClient(eXosip_t *ctx){

  fprintf(stdout, "Register client\n");

  // Initialize a registration
  osip_message_t *reg = NULL;
  int rid;
  int i;

  eXosip_lock(ctx);
  rid = eXosip_register_build_initial_register(ctx, "sip:address@hidden", "sip.antisip.com", NULL, 1800, &reg);


  osip_message_set_supported(reg, "100rel");
  osip_message_set_supported(reg, "path");

  i = eXosip_register_send_register(ctx, rid, reg);
  eXosip_unlock(ctx);

  eXosip_event_t *evt;
  while(true){

    fprintf(stderr, "Start\n");
    fprintf(stderr, "%d\n", rid);
    
    evt = eXosip_event_wait(ctx, 0, 50);
    eXosip_lock(ctx);
    eXosip_automatic_action(ctx);
    eXosip_unlock(ctx);
    
    fprintf(stderr, "Check event\n");

    if(evt == NULL){
      fprintf(stderr, "NULL\n");
      continue;
    }

    if(evt->type == EXOSIP_REGISTRATION_SUCCESS){
      fprintf(stderr, "Success\n");
      break;
    }else if(evt->type == EXOSIP_REGISTRATION_FAILURE){
      fprintf(stderr, "Failure\n");
      break;
    }

    fprintf(stderr, "%d\n", evt->type);
  }

  fprintf(stderr, "Out of the loop");

  return i;

}


_______________________________________________
osip-dev mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/osip-dev




--
Antisip - http://www.antisip.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]