* Moved the call to GetAuthBasic()
authorArt Cancro <ajc@citadel.org>
Thu, 6 Aug 2009 20:00:16 +0000 (20:00 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 6 Aug 2009 20:00:16 +0000 (20:00 +0000)
webcit/context_loop.c

index 78e4a6cbd7c748563b2c7756a04e2b41c51049b8..17c549174ebc4f153ade571a6589bcaf3c0a610d 100644 (file)
@@ -141,6 +141,10 @@ wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t
        wcsession *sptr = NULL;
        wcsession *TheSession = NULL;   
        
+       if (Hdr->HR.got_auth == AUTH_BASIC) {
+               GetAuthBasic(Hdr);
+       }
+
        pthread_mutex_lock(ListMutex);
        for (sptr = *wclist; ((sptr != NULL) && (TheSession == NULL)); sptr = sptr->next) {
                
@@ -150,7 +154,6 @@ wcsession *FindSession(wcsession **wclist, ParsedHttpHdrs *Hdr, pthread_mutex_t
                case AUTH_BASIC:
                        if ( (Hdr->HR.SessionKey != sptr->SessionKey))
                                continue;
-                       GetAuthBasic(Hdr);
                        if ((!strcasecmp(ChrPtr(Hdr->c_username), ChrPtr(sptr->wc_username))) &&
                            (!strcasecmp(ChrPtr(Hdr->c_password), ChrPtr(sptr->wc_password))) ) {
                                TheSession = sptr;
@@ -175,8 +178,7 @@ wcsession *CreateSession(int Lockable, wcsession **wclist, ParsedHttpHdrs *Hdr,
 {
        wcsession *TheSession;
        lprintf(3, "Creating a new session\n");
-       TheSession = (wcsession *)
-               malloc(sizeof(wcsession));
+       TheSession = (wcsession *) malloc(sizeof(wcsession));
        memset(TheSession, 0, sizeof(wcsession));
        TheSession->Hdr = Hdr;
        TheSession->SessionKey = Hdr->HR.SessionKey;
@@ -536,11 +538,6 @@ void context_loop(ParsedHttpHdrs *Hdr)
        if (TheSession == NULL) {
                TheSession = CreateSession(1, &SessionList, Hdr, &SessionListMutex);
 
-               /* Yes, theoretically we did this already, but for some reason c_username and c_password
-                * are already gone by now, so we fetch them again.
-                */
-               GetAuthBasic(Hdr);
-
                if ((StrLength(Hdr->c_username) == 0) && (!Hdr->HR.DontNeedAuth)) {
 
                        if ((Hdr->HR.Handler != NULL) &&