Tim (visions) wrote in lj_dev,


brad asked me to help out with changing mod_latency to behave properly with vhosts. i started working on it, but i have some other things that i need to do at the moment.

so, the goal is to make SetLatency act on a virtual server level instead of on all servers hosted on that machine. The gist of what it needs to do is below. However, it needs to be done dynamically (by figuring out what section it is and storing that some way), not hardcoded like what is in here (which isn't tested either.. just thrown together).

anyway, if someone wants to pick up where i left off, by all means do. i wont be able to get to it again till this weekend.

however, i did find this... mod_throttle which seems to do exactly what lj needs... and then we could just do away with mod_latency. also, someone could take the code in mod_throttle and use it to mod mod_latency appropriately. brad? wanna switch to using mod_throttle instead? adding a simple sleep doesnt do much to truly help. there is also mod_bandwidth as well, but it doesnt quite apply as much.

visions@goathack:~/cvs/ljcom/src/mod_latency$ cvs diff mod_latency.c
Index: mod_latency.c
RCS file: /home/cvslj/ljcom/src/mod_latency/mod_latency.c,v
retrieving revision 1.1
diff -u -r1.1 mod_latency.c
--- mod_latency.c       19 Mar 2002 00:51:19 -0000      1.1
+++ mod_latency.c       28 Mar 2002 03:12:22 -0000
@@ -18,14 +18,35 @@

 const char *latency_set(cmd_parms *cmd, void *dummy, const char *arg)
-  latency_val.tv_nsec = atoi(arg) * 1e6 - 1;
-  return NULL;
+    mva_sconf_t *conf;
+    conf = (mva_sconf_t *)ap_get_module_config(cmd->server->module_config,
+                                                &latency_module);
+    /* do something with the config file here..
+       figuring out what virt server it applies to */
+    latency_val.tv_nsec = atoi(arg) * 1e6 - 1;
+    return NULL;

 static int do_pause (request_rec *r)
-  nanosleep(&latency_val, NULL);
-  return OK;
+    server_rec *vhost;
+    short_score score_record;
+    parent_score ps_record;
+    for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
+        score_record = ap_scoreboard_image->servers[i];
+        ps_record = ap_scoreboard_image->parent[i];
+        vhost = score_record.vhostrec;
+        if (ps_record.generation != ap_my_generation) {
+           vhost = NULL;
+        }
+    }
+    if (strcmp(vhost, "img.livejournal.com") != 0) {
+        nanosleep(&latency_val, NULL);
+    }
+    return OK;

 command_rec latency_cmds[] = {
  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 1 comment