datapath: Get rid of query operations for single flows.
[openvswitch] / lib / cfg.c
index 194fb1890a086d6763e2557a2e9782060d08dc35..901315ed99cd83d0f8b333a7e8e03247734f66c8 100644 (file)
--- a/lib/cfg.c
+++ b/lib/cfg.c
@@ -143,22 +143,15 @@ cfg_set_file(const char *file_name)
 static int
 update_cookie(void)
 {
+    struct sha1_ctx context;
     int i;
-    SHA1Context context;
 
-    if (SHA1Reset(&context) != shaSuccess) {
-        return -1;
-    }
+    sha1_init(&context);
     for (i = 0; i < cfg.n; i++) {
-        if (SHA1Input(&context, (uint8_t *)cfg.names[i], 
-                    strlen(cfg.names[i])) != shaSuccess) {
-            return -1;
-        }
-        SHA1Input(&context, (uint8_t *)"\n", 1);
-    }
-    if (SHA1Result(&context, cfg_cookie) != shaSuccess) {
-        return -1;
+        sha1_update(&context, cfg.names[i], strlen(cfg.names[i]));
+        sha1_update(&context, "\n", 1);
     }
+    sha1_final(&context, cfg_cookie);
 
     return 0;
 }
@@ -339,13 +332,16 @@ try_lock(int fd, bool block)
 int
 cfg_lock(uint8_t *cookie, int timeout)
 {
-    long long int start = time_msec();
+    long long int start;
     long long int elapsed = 0;
     int fd;
     uint8_t curr_cookie[CFG_COOKIE_LEN];
 
     assert(lock_fd < 0);
     COVERAGE_INC(cfg_lock);
+
+    time_refresh();
+    start = time_msec();
     for (;;) {
         int error;