Connection Objects Initialization

This hook function, if defined, is called every time an instance is initialized as shown in the figure Hook Functions. This function should be used to initialize application' objects for a web server instance. As example this function can be used to Initialize the memory pool and chained list for session or initialize a periodic timer which check for expired session and release them if it is the case. 

Prototype

          void  HTTPs_InstanceInitHook (const  HTTPs_INSTANCE  *p_instance,
                                        const  void            *p_hook_cfg);

Arguments

p_instance

Pointer to the instance structure (read only).

p_hook_cfg

Pointer to hook application data.

Return Values

None.

Required Configuration

See section Hook Configuration.

Notes / Warnings

None.

Example Template

Listing - HTTPs Instance Initialization Example Code
typedef  struct  HTTPs_Session  HTTPs_SESSION;


struct  HTTPs_Session{
	CPU_INT16U      SessionID;
    CLK_TS_SEC      ExpireTS;
    HTTPs_SESSION  *NextPtr;
    HTTPs_SESSION  *PrevPtr;
};


static  MEM_DYN_POOL    SessionPool;
static  HTTPs_SESSION  *SessionFirstPtr;
static  OS_TMR 			SesssionIDReleaseTMR;
 
void  HTTPs_InstanceInitHook (const  HTTPs_INSTANCE  *p_instance,
                              const  void            *p_hook_cfg)
{
	CPU_SIZE_T  octets_reqd;
	LIB_ERR     err;
	OS_ERR      err_os;


    Mem_DynPoolCreate("HTTPs Instance Session Pool",
                      &SessionPool,                             /* Create the session memory pool.                      */
                       DEF_NULL,
                       sizeof(HTTPs_SESSION),
                       sizeof(CPU_ALIGN),
                       HTTPs_USER_LOGGED_MAX_NBR,
                       HTTPs_USER_LOGGED_MAX_NBR,
                      &err);
    															/* Set the first pointer to NULL which indicate ...		*/
    SessionFirstPtr = DEF_NULL;                                 /* there is no active session.							*/

                                                                /* Create and Start the timer which check for ...       */
                                                                /* releasing expired session.                           */
    OSTmrCreate(&SesssionIDReleaseTMR,
                 HTTPs_SESSION_RELEASE_TMR_NAME_STR,
                 0,
                 OSCfg_TmrTaskRate_Hz,
                 OS_OPT_TMR_PERIODIC,
                &HTTPs_LoginReleaseSessionIDTmr,
                 DEF_NULL,
                &err_os);

	OSTmrStart(&SesssionIDReleaseTMR, &err_os);
}