Index: pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c	(revision 3443)
+++ pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c	(revision 3444)
@@ -392,13 +392,4 @@
 }
 
-PJ_DEF(pj_status_t)
-pjsip_regc_set_delay_before_refresh( pjsip_regc *regc,
-				     pj_uint32_t delay )
-{
-    PJ_ASSERT_RETURN(regc, PJ_EINVAL);
-    regc->delay_before_refresh = delay;
-    return PJ_SUCCESS;
-}
-
 PJ_DEF(pj_status_t) pjsip_regc_set_credentials( pjsip_regc *regc,
 						int count,
@@ -783,4 +774,54 @@
     }
 }
+
+static void schedule_registration ( pjsip_regc *regc, pj_int32_t expiration )
+{
+    if (regc->auto_reg && expiration > 0) {
+        pj_time_val delay = { 0, 0};
+
+        delay.sec = expiration - regc->delay_before_refresh;
+        if (regc->expires != PJSIP_REGC_EXPIRATION_NOT_SPECIFIED && 
+            delay.sec > (pj_int32_t)regc->expires) 
+        {
+            delay.sec = regc->expires;
+        }
+        if (delay.sec < DELAY_BEFORE_REFRESH) 
+            delay.sec = DELAY_BEFORE_REFRESH;
+        regc->timer.cb = &regc_refresh_timer_cb;
+        regc->timer.id = REFRESH_TIMER;
+        regc->timer.user_data = regc;
+        pjsip_endpt_schedule_timer( regc->endpt, &regc->timer, &delay);
+        pj_gettimeofday(&regc->last_reg);
+        regc->next_reg = regc->last_reg;
+        regc->next_reg.sec += delay.sec;
+    }
+}
+
+PJ_DEF(pj_status_t)
+pjsip_regc_set_delay_before_refresh( pjsip_regc *regc,
+				     pj_uint32_t delay )
+{
+    PJ_ASSERT_RETURN(regc, PJ_EINVAL);
+
+    if (delay > regc->expires)
+        return PJ_ETOOBIG;
+
+    if (regc->delay_before_refresh != delay)
+    {
+        regc->delay_before_refresh = delay;
+
+        if (regc->timer.id != 0) {
+            /* Cancel registration timer */
+            pjsip_endpt_cancel_timer(regc->endpt, &regc->timer);
+            regc->timer.id = 0;
+
+            /* Schedule next registration */
+            schedule_registration(regc, regc->expires);
+        }
+    }
+
+    return PJ_SUCCESS;
+}
+
 
 static pj_int32_t calculate_response_expiration(const pjsip_regc *regc,
@@ -1128,23 +1169,5 @@
 
 	    /* Schedule next registration */
-	    if (regc->auto_reg && expiration > 0) {
-		pj_time_val delay = { 0, 0};
-
-		delay.sec = expiration - regc->delay_before_refresh;
-		if (regc->expires != PJSIP_REGC_EXPIRATION_NOT_SPECIFIED && 
-		    delay.sec > (pj_int32_t)regc->expires) 
-		{
-		    delay.sec = regc->expires;
-		}
-		if (delay.sec < DELAY_BEFORE_REFRESH) 
-		    delay.sec = DELAY_BEFORE_REFRESH;
-		regc->timer.cb = &regc_refresh_timer_cb;
-		regc->timer.id = REFRESH_TIMER;
-		regc->timer.user_data = regc;
-		pjsip_endpt_schedule_timer( regc->endpt, &regc->timer, &delay);
-		pj_gettimeofday(&regc->last_reg);
-		regc->next_reg = regc->last_reg;
-		regc->next_reg.sec += delay.sec;
-	    }
+            schedule_registration(regc, expiration);
 
 	} else {
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 3443)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c	(revision 3444)
@@ -946,9 +946,13 @@
     /* Registration */
     acc->cfg.reg_timeout = cfg->reg_timeout;
-    acc->cfg.reg_delay_before_refresh = cfg->reg_delay_before_refresh;
     acc->cfg.unreg_timeout = cfg->unreg_timeout;
     acc->cfg.allow_contact_rewrite = cfg->allow_contact_rewrite;
     acc->cfg.reg_retry_interval = cfg->reg_retry_interval;
     acc->cfg.drop_calls_on_reg_fail = cfg->drop_calls_on_reg_fail;
+    if (acc->cfg.reg_delay_before_refresh != cfg->reg_delay_before_refresh) {
+        acc->cfg.reg_delay_before_refresh = cfg->reg_delay_before_refresh;
+        pjsip_regc_set_delay_before_refresh(acc->regc,
+                                            cfg->reg_delay_before_refresh);
+    }
 
     /* Normalize registration timeout and refresh delay */
