Fixed bug in event subscription when it is challenged/authenticated

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@424 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/src/pjsip-simple/evsub.c b/pjsip/src/pjsip-simple/evsub.c
index 9a9b852..7b13d54 100644
--- a/pjsip/src/pjsip-simple/evsub.c
+++ b/pjsip/src/pjsip-simple/evsub.c
@@ -1355,10 +1355,6 @@
 
 	sub->pending_sub = tsx;
 
-    } else if (tsx == sub->pending_sub &&
-	       tsx->state >= PJSIP_TSX_STATE_COMPLETED)
-    {
-	sub->pending_sub = NULL;
     }
 
     return sub;
@@ -1468,6 +1464,10 @@
 	    return;
 	}
 
+	/* Clear pending subscription */
+	if (tsx == sub->pending_sub)
+	    sub->pending_sub = NULL;
+
 	/* Handle authentication. */
 	if (tsx->status_code==401 || tsx->status_code==407) {
 	    pjsip_tx_data *tdata;