osip-dev
[Top][All Lists]
Advanced

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

Re: [osip-dev] problem with eXosip_register_build_initial_register_withq


From: Aymeric Moizard
Subject: Re: [osip-dev] problem with eXosip_register_build_initial_register_withqvalue
Date: Thu, 20 Oct 2016 07:52:25 +0200

Hi Christoph,

I have commited the 2 changes and pushed them in the git!

About your change:
_eXosip_pub_free(excontext->j_pub, pub);
must be
_eXosip_pub_free(excontext, pub);

and it must be inside the {}:

if (element_added)

    {
       REMOVE_ELEMENT (excontext->j_pub, pub);
       _eXosip_pub_free(excontext, pub);
    }

Let me know, if it seems all fine!

Regards

Aymeric



2016-10-18 12:06 GMT+02:00 FEICHTER Christoph <address@hidden>:

hi aymeric,

 

ok, so you use REMOVE_ELEMENT instead of eXosip_register_remove, right ?

… I am interested in your fix and did a ‘git pull’, but I could not yet find you changes.

… probably because you are on travel  ;-)

 

btw: there is a similar issue with publications !

                here is the suggested fix marked in yellow:

 

int

eXosip_publish (struct eXosip_t *excontext, osip_message_t * message, const char *to)

{

  osip_transaction_t *transaction;

  osip_event_t *sipevent;

  int i;

  eXosip_pub_t *pub = NULL;

  int element_added = FALSE;

 

  if (message == NULL)

    return OSIP_BADPARAMETER;

  if (message->cseq == NULL || message->cseq->number == NULL) {

    osip_message_free (message);

    return OSIP_SYNTAXERROR;

  }

  if (to == NULL) {

    osip_message_free (message);

    return OSIP_BADPARAMETER;

  }

 

  i = _eXosip_pub_find_by_aor (excontext, &pub, to);

  if (i != 0 || pub == NULL) {

    osip_header_t *expires;

 

    osip_message_get_expires (message, 0, &expires);

    if (expires == NULL || expires->hvalue == NULL) {

      OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: missing expires header in PUBLISH!"));

      osip_message_free (message);

      return OSIP_SYNTAXERROR;

    }

    else {

      /* start a new publication context */

      i = _eXosip_pub_init (excontext, &pub, to, expires->hvalue);

      if (i != 0) {

        osip_message_free (message);

        return i;

      }

      ADD_ELEMENT (excontext->j_pub, pub);

      element_added = TRUE;

    }

  }

  else {

    if (pub->p_sip_etag[0] != '\0') {

      /* increase cseq */

      osip_message_set_header (message, "SIP-If-Match", pub->p_sip_etag);

    }

 

    {

      osip_header_t *expires;

 

      osip_message_get_expires (message, 0, &expires);

      if (expires == NULL || expires->hvalue == NULL) {

        OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: missing expires header in PUBLISH!"));

        osip_message_free (message);

        return OSIP_SYNTAXERROR;

      }

      pub->p_period = atoi (expires->hvalue);

    }

 

    if (pub->p_last_tr != NULL && pub->p_last_tr->cseq != NULL && pub->p_last_tr->cseq->number != NULL) {

      int osip_cseq_num = osip_atoi (pub->p_last_tr->cseq->number);

      int length = (int) strlen (pub->p_last_tr->cseq->number);

 

      osip_cseq_num++;

     osip_free (message->cseq->number);

      message->cseq->number = (char *) osip_malloc (length + 2);        /* +2 like for 9 to 10 */

      if (message->cseq->number == NULL) {

        osip_message_free (message);

        return OSIP_NOMEM;

      }

      snprintf (message->cseq->number, length + 2, "%i", osip_cseq_num);

    }

  }

 

  i = _eXosip_transaction_init (excontext, &transaction, NICT, excontext->j_osip, message);

  if (i != 0) {

    osip_message_free (message);

    if (element_added)

    {

       REMOVE_ELEMENT (excontext->j_pub, pub);

    }

    _eXosip_pub_free(excontext->j_pub, pub);

    return i;

  }

 

  if (pub->p_last_tr != NULL)

    osip_list_add (&excontext->j_transactions, pub->p_last_tr, 0);

  pub->p_last_tr = transaction;

 

  sipevent = osip_new_outgoing_sipmessage (message);

  sipevent->transactionid = transaction->transactionid;

 

  osip_transaction_add_event (transaction, sipevent);

  _eXosip_wakeup (excontext);

  return transaction->transactionid;

}

 

br,

Christoph

 

 

 

From: Aymeric Moizard [mailto:address@hidden]
Sent: Dienstag, 18. Oktober 2016 04:27
To: FEICHTER Christoph
Cc: address@hidden
Subject: Re: [osip-dev] problem with eXosip_register_build_initial_register_withqvalue

 

Hi Chrisptoph,

 

I did a fix in the git. I only remove the context if it was previously created.

Also, because we already have the context, I do not call the method "remove"

because it would add an extra search.

 

Tks a lot

Aymeric

 

 

2016-10-17 18:47 GMT+02:00 Aymeric Moizard <address@hidden>:

Hi Christophe!

I will check the issue later! I'm travelling now.

Tks for reporting!
Regards
Aymeric

 

Le 17 oct. 2016 8:26 PM, "FEICHTER Christoph" <Christoph.FEICHTER@frequentis.com> a écrit :

hi,

 

I found a problem with eXosip_register_build_initial_register_withqvalue.

 

suggest the following:

the app calls eXosip_register_build_initial_register

which internally maps to eXosip_register_build_initial_register_withqvalue

_eXosip_reg_init was successful – thus,

 

                ADD_ELEMENT (excontext->j_reg, jr);

 

has been called.

now, if  _eXosip_register_build_register fails,

the app has not chance to call  eXosip_register_remove for removing the registration,

because no rid has been passed to the app as return-value of eXosip_register_build_initial_register !!

 

with subsequent retries of eXosip_register_build_initial_register

the list excontext->j_reg ecomes bigger and bigger.

 

 

I suggest to  cleanup internally, in case that eXosip_register_build_initial_register fails:

 

 

int

eXosip_register_build_initial_register_withqvalue (struct eXosip_t *excontext, const char *from, const char *proxy, const char *contact, int expires, const char *qvalue, osip_message_t ** reg)

{

  ...

 

  i = _eXosip_register_build_register (excontext, jr, reg);

  if (i != 0) {

    OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: cannot build REGISTER!\n"));

    *reg = NULL;

    eXosip_register_remove (excontext, jr->r_id);

    return i;

  }

 

  return jr->r_id;

}

 

 

br,

Christoph

 

 

 

_______________________________________________
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]