/[radius]/radius/radiusd/sql.c
ViewVC logotype

Diff of /radius/radiusd/sql.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.63 by gray, Sat Jul 19 22:15:36 2003 UTC revision 1.64 by gray, Mon Jul 21 07:39:34 2003 UTC
# Line 619  sql_cache_destroy(struct sql_connection Line 619  sql_cache_destroy(struct sql_connection
619  static void  static void
620  sql_cache_insert(struct sql_connection *conn, SQL_RESULT *res)  sql_cache_insert(struct sql_connection *conn, SQL_RESULT *res)
621  {  {
622          debug(1,("cache: %d,(%d,%d)",sql_cache_level(conn),conn->head,conn->tail));          debug(20,
623                  ("cache: %d,(%d,%d)",
624                   sql_cache_level(conn),conn->head,conn->tail));
625          if (sql_cache_level(conn) >= SQL_CACHE_SIZE-1) {          if (sql_cache_level(conn) >= SQL_CACHE_SIZE-1) {
626                  sql_result_destroy(conn->cache[conn->head]);                  sql_result_destroy(conn->cache[conn->head]);
627                  conn->head = (conn->head + 1) % SQL_CACHE_SIZE;                  conn->head = (conn->head + 1) % SQL_CACHE_SIZE;
628                  debug(1,("head: %d,%d", conn->head,conn->tail));                  debug(20,("head: %d,%d", conn->head,conn->tail));
629          }          }
630          debug(1,("inserting at pos %d", conn->tail));          debug(20,("inserting at pos %d", conn->tail));
631          conn->cache[conn->tail] = res;          conn->cache[conn->tail] = res;
632          conn->tail = (conn->tail + 1) % SQL_CACHE_SIZE;          conn->tail = (conn->tail + 1) % SQL_CACHE_SIZE;
633          debug(1,("tail: %d,%d", conn->head,conn->tail));          debug(20,("tail: %d,%d", conn->head,conn->tail));
634  }  }
635    
636  static SQL_RESULT *  static SQL_RESULT *
# Line 638  sql_cache_retrieve(struct sql_connection Line 640  sql_cache_retrieve(struct sql_connection
640          SQL_RESULT *res;          SQL_RESULT *res;
641          size_t i;          size_t i;
642                    
643          debug(1,("query: %s",query));          debug(20,("query: %s",query));
644          res = emalloc(sizeof(*res));          res = emalloc(sizeof(*res));
645          res->query = estrdup(query);          res->query = estrdup(query);
646          res->nfields = res->ntuples = 0;          res->nfields = res->ntuples = 0;
# Line 683  sql_cache_lookup(struct sql_connection * Line 685  sql_cache_lookup(struct sql_connection *
685  {  {
686          size_t i;          size_t i;
687    
688          debug(1,("looking up %s", query));          debug(20,("looking up %s", query));
689          for (i = conn->head; i != conn->tail;          for (i = conn->head; i != conn->tail;
690               i = (i + 1) % SQL_CACHE_SIZE) {               i = (i + 1) % SQL_CACHE_SIZE) {
691                  if (strcmp(conn->cache[i]->query, query) == 0) {                  if (strcmp(conn->cache[i]->query, query) == 0) {
692                          debug(1,("found at %d", i));                          debug(20,("found at %d", i));
693                          return conn->cache[i];                          return conn->cache[i];
694                  }                  }
695          }          }
696          debug(1,("NOT FOUND"));          debug(20,("NOT FOUND"));
697          return NULL;          return NULL;
698  }  }
699    

Legend:
Removed from v.1.63  
changed lines
  Added in v.1.64

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26