Definition in file session.h.
#include "utils.h"
Go to the source code of this file.
Data Structures | |
| struct | session |
| Structure for session identification. More... | |
Defines | |
| #define | SESSION_STATE_MAINTAINED 0 |
| Keep the session state. | |
| #define | SESSION_NO_STATE_MAINTAINED 1 |
| Don't keep the session state. | |
Functions | |
| int | session_init () |
| Initializes the session related structures. | |
| int | session_destroy () |
| Destroys the session related structures. | |
| #define SESSION_NO_STATE_MAINTAINED 1 |
| int session_init | ( | ) |
Initializes the session related structures.
Definition at line 72 of file session.c.
References LOG_NO_MEM, session_id1, session_id2, and session_lock.
Referenced by diameter_peer_init().
00073 { 00074 session_lock = lock_alloc(); 00075 if (!session_lock){ 00076 LOG_NO_MEM("lock",sizeof(gen_lock_t)); 00077 goto error; 00078 } 00079 session_lock = lock_init(session_lock); 00080 session_id1 = shm_malloc(sizeof(unsigned int)); 00081 if (!session_id1){ 00082 LOG_NO_MEM("shm",sizeof(unsigned int)); 00083 goto error; 00084 } 00085 session_id2 = shm_malloc(sizeof(unsigned int)); 00086 if (!session_id2){ 00087 LOG_NO_MEM("shm",sizeof(unsigned int)); 00088 goto error; 00089 } 00090 srand((unsigned int)time(0)); 00091 *session_id1 = rand(); 00092 *session_id1 <<= 16; 00093 *session_id1 += time(0)&0xFFFF; 00094 *session_id2 = 0; 00095 return 1; 00096 error: 00097 return 0; 00098 }
| int session_destroy | ( | ) |
Destroys the session related structures.
Definition at line 103 of file session.c.
References session_id1, session_id2, and session_lock.
Referenced by diameter_peer_destroy().
00104 { 00105 lock_get(session_lock); 00106 lock_destroy(session_lock); 00107 lock_dealloc((void*)session_lock); 00108 shm_free(session_id1); 00109 shm_free(session_id2); 00110 return 1; 00111 }
1.5.2