Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

dlr_mem.c File Reference

#include "gwlib/gwlib.h"
#include "dlr_p.h"

Include dependency graph for dlr_mem.c:

Include dependency graph

Go to the source code of this file.

Functions

void dlr_mem_shutdown ()
long dlr_mem_messages (void)
void dlr_mem_flush (void)
void dlr_mem_add (struct dlr_entry *dlr)
int dlr_mem_entry_match (struct dlr_entry *dlr, const Octstr *smsc, const Octstr *ts, const Octstr *dst)
dlr_entrydlr_mem_get (const Octstr *smsc, const Octstr *ts, const Octstr *dst)
void dlr_mem_remove (const Octstr *smsc, const Octstr *ts, const Octstr *dst)
dlr_storagedlr_init_mem (Cfg *cfg)

Variables

Listdlr_waiting_list
RWLock rwlock
dlr_storage handles


Function Documentation

struct dlr_storage* dlr_init_mem Cfg cfg  ) 
 

Definition at line 195 of file dlr_mem.c.

References dlr_waiting_list, gw_rwlock_init_static(), gwlist_create, and rwlock.

Referenced by dlr_init().

00196 {
00197     dlr_waiting_list = gwlist_create();
00198     gw_rwlock_init_static(&rwlock);
00199 
00200     return &handles;
00201 }

Here is the call graph for this function:

void dlr_mem_add struct dlr_entry dlr  )  [static]
 

Definition at line 112 of file dlr_mem.c.

References dlr_waiting_list, gw_rwlock_unlock(), gw_rwlock_wrlock(), gwlist_append(), and rwlock.

00113 {
00114     gw_rwlock_wrlock(&rwlock);
00115     gwlist_append(dlr_waiting_list,dlr);
00116     gw_rwlock_unlock(&rwlock);
00117 }

Here is the call graph for this function:

int dlr_mem_entry_match struct dlr_entry dlr,
const Octstr smsc,
const Octstr ts,
const Octstr dst
[static]
 

Definition at line 123 of file dlr_mem.c.

References octstr_compare(), dlr_entry::smsc, and dlr_entry::timestamp.

Referenced by dlr_mem_get(), and dlr_mem_remove().

00124 {
00125     /* XXX: check destination addr too, because e.g. for UCP is not enough to check only
00126      *          smsc and timestamp (timestamp is even without milliseconds)
00127      */
00128     if(octstr_compare(dlr->smsc,smsc) == 0 && octstr_compare(dlr->timestamp,ts) == 0)
00129         return 0;
00130 
00131     return 1;
00132 }

Here is the call graph for this function:

void dlr_mem_flush void   )  [static]
 

Definition at line 97 of file dlr_mem.c.

References dlr_waiting_list, gw_rwlock_unlock(), gw_rwlock_wrlock(), gwlist_delete(), gwlist_len(), and rwlock.

00098 {
00099     long i;
00100     long len;
00101 
00102     gw_rwlock_wrlock(&rwlock);
00103     len = gwlist_len(dlr_waiting_list);
00104     for (i=0; i < len; i++)
00105         gwlist_delete(dlr_waiting_list, i, 1);
00106     gw_rwlock_unlock(&rwlock);
00107 }

Here is the call graph for this function:

struct dlr_entry* dlr_mem_get const Octstr smsc,
const Octstr ts,
const Octstr dst
[static]
 

Definition at line 137 of file dlr_mem.c.

References dlr_entry_duplicate(), dlr_mem_entry_match(), dlr_waiting_list, gw_rwlock_rdlock(), gw_rwlock_unlock(), gwlist_get(), gwlist_len(), and rwlock.

00138 {
00139     long i;
00140     long len;
00141     struct dlr_entry *dlr = NULL, *ret = NULL;
00142 
00143     gw_rwlock_rdlock(&rwlock);
00144     len = gwlist_len(dlr_waiting_list);
00145     for (i=0; i < len; i++) {
00146         dlr = gwlist_get(dlr_waiting_list, i);
00147 
00148         if (dlr_mem_entry_match(dlr, smsc, ts, dst) == 0) {
00149             ret = dlr_entry_duplicate(dlr);
00150             break;
00151         }
00152     }
00153     gw_rwlock_unlock(&rwlock);
00154 
00155     /* we couldnt find a matching entry */
00156     return ret;
00157 }

Here is the call graph for this function:

long dlr_mem_messages void   )  [static]
 

Definition at line 92 of file dlr_mem.c.

References dlr_waiting_list, and gwlist_len().

00093 {
00094     return gwlist_len(dlr_waiting_list);
00095 }

Here is the call graph for this function:

void dlr_mem_remove const Octstr smsc,
const Octstr ts,
const Octstr dst
[static]
 

Definition at line 162 of file dlr_mem.c.

References dlr_entry_destroy(), dlr_mem_entry_match(), dlr_waiting_list, gw_rwlock_unlock(), gw_rwlock_wrlock(), gwlist_delete(), gwlist_get(), gwlist_len(), and rwlock.

00163 {
00164     long i;
00165     long len;
00166     struct dlr_entry *dlr = NULL;
00167 
00168     gw_rwlock_wrlock(&rwlock);
00169     len = gwlist_len(dlr_waiting_list);
00170     for (i=0; i < len; i++) {
00171         dlr = gwlist_get(dlr_waiting_list, i);
00172 
00173         if (dlr_mem_entry_match(dlr, smsc, ts, dst) == 0) {
00174             gwlist_delete(dlr_waiting_list, i, 1);
00175             dlr_entry_destroy(dlr);
00176             break;
00177         }
00178     }
00179     gw_rwlock_unlock(&rwlock);
00180 }

Here is the call graph for this function:

void dlr_mem_shutdown  )  [static]
 

Definition at line 81 of file dlr_mem.c.

References dlr_entry_destroy(), dlr_waiting_list, gw_rwlock_destroy(), gw_rwlock_unlock(), gw_rwlock_wrlock(), gwlist_destroy(), gwlist_item_destructor_t, and rwlock.

00082 {
00083     gw_rwlock_wrlock(&rwlock);
00084     gwlist_destroy(dlr_waiting_list, (gwlist_item_destructor_t *)dlr_entry_destroy);
00085     gw_rwlock_unlock(&rwlock);
00086     gw_rwlock_destroy(&rwlock);
00087 }

Here is the call graph for this function:


Variable Documentation

List* dlr_waiting_list [static]
 

Definition at line 75 of file dlr_mem.c.

Referenced by dlr_init_mem(), dlr_mem_add(), dlr_mem_flush(), dlr_mem_get(), dlr_mem_messages(), dlr_mem_remove(), and dlr_mem_shutdown().

struct dlr_storage handles [static]
 

Initial value:

 {
    .type = "internal",
    .dlr_add = dlr_mem_add,
    .dlr_get = dlr_mem_get,
    .dlr_remove = dlr_mem_remove,
    .dlr_shutdown = dlr_mem_shutdown,
    .dlr_messages = dlr_mem_messages,
    .dlr_flush = dlr_mem_flush
}

Definition at line 182 of file dlr_mem.c.

RWLock rwlock [static]
 

Definition at line 76 of file dlr_mem.c.

Referenced by dlr_init_mem(), dlr_mem_add(), dlr_mem_flush(), dlr_mem_get(), dlr_mem_remove(), and dlr_mem_shutdown().

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.