Navigation


Changeset 278:50bfb29bf036 in freeDiameter


Ignore:
Timestamp:
Apr 23, 2010, 5:22:09 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Try better handling several pending requests for the same session (not very clean yet)

Location:
extensions/app_radgw
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_radgw/rgw_clients.c

    r271 r278  
    260260                rgw_msg_free(msg);
    261261        } else {
    262                 /* Update information for new message */
    263                 if (cli->last[idx].ans) {
    264                         /* Free it */
    265                         radius_msg_free(cli->last[idx].ans);
    266                         free(cli->last[idx].ans);
    267                         cli->last[idx].ans = NULL;
    268                 }
    269                 cli->last[idx].id = (*msg)->radius.hdr->identifier;
    270                 cli->last[idx].port = (*msg)->port;
     262                /* We have not just received this message already */
     263                if (cli->last[idx].port == 0) { /* first message from this client */
     264                        /* Just add the new information */
     265                        ASSERT(cli->last[idx].ans == NULL);
     266                        cli->last[idx].id = (*msg)->radius.hdr->identifier;
     267                        cli->last[idx].port = (*msg)->port;
     268                } else {
     269                        /* We have got previous message(s), update the info only if answered already */
     270                        if (cli->last[idx].ans) {
     271                                cli->last[idx].id = (*msg)->radius.hdr->identifier;
     272                                cli->last[idx].port = (*msg)->port;
     273                                /* Free the previous answer */
     274                                radius_msg_free(cli->last[idx].ans);
     275                                free(cli->last[idx].ans);
     276                                cli->last[idx].ans = NULL;
     277                        }
     278                }
    271279        }
    272280       
     
    607615        }
    608616        cli->last[idx].ans = *msg;
     617        cli->last[idx].id = req->radius.hdr->identifier;
     618        cli->last[idx].port = req->port;
    609619        *msg = NULL;
    610620       
  • extensions/app_radgw/rgw_msg.c

    r258 r278  
    268268        if (*session) {
    269269                CHECK_FCT( fd_sess_getsid(*session, &sess_str) );
    270                 TRACE_DEBUG(FULL, "Session '%s' has been successfully %s.", sess_str, idx ? "created" : "retrieved");
     270                if (idx == 0) {
     271                        TRACE_DEBUG(INFO, "Another message was translated for this session ('%s') and not answered yet, discarding the new RADIUS request.", sess_str);
     272                        *session = NULL;
     273                        return EALREADY;
     274                }
     275               
     276                TRACE_DEBUG(FULL, "Translating new message for session '%s'...", sess_str);
    271277               
    272278                /* Add the Session-Id AVP as first AVP */
  • extensions/app_radgw/rgw_worker.c

    r271 r278  
    147147                        {
    148148                                /* An error occurred, discard message */
     149                                if (diam_msg) {
     150                                        CHECK_FCT_DO( fd_msg_free(diam_msg), );
     151                                        diam_msg = NULL;
     152                                }
     153                                if (session) {
     154                                        CHECK_FCT_DO( fd_sess_destroy(&session), );
     155                                }
    149156                                rgw_msg_free(&msg);
    150157                                rgw_clients_dispose(&cli);
     
    153160                if (msg == NULL) {
    154161                        rgw_clients_dispose(&cli);
     162                        if (diam_msg) {
     163                                CHECK_FCT_DO( fd_msg_free(diam_msg), );
     164                                diam_msg = NULL;
     165                        }
     166                        if (session) {
     167                                CHECK_FCT_DO( fd_sess_destroy(&session), );
     168                        }
    155169                        continue; /* the message was handled already */
    156170                }
     
    176190                }
    177191               
    178                 /* Check the session is correct */
     192                /* Check the session is correct (for debug) */
    179193                ASSERT(session != NULL);
    180194               
     
    298312        }
    299313       
     314        /* Clear the RADIUS request */
     315        if (pa->rad) {
     316                rgw_msg_free(&pa->rad);
     317        }
     318       
    300319        /* Release reference on the client */
    301320        rgw_clients_dispose(&pa->cli);
Note: See TracChangeset for help on using the changeset viewer.