Althttpd

Check-in [f6f3b8dd2d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Move the calculation of the request start time up to resolve problem where log writes can be sent to the wrong file when running in standalone server mode, as discussed in /forumpost/0e8dfd8d02bccd4a.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f6f3b8dd2dd43735577f7eed2f7ee923ec276d1c09e6c80082c99f8b10747e81
User & Date: stephan 2025-01-24 13:15:35
References
2025-02-11
13:29 Reply: Logfile name datetime interpolation ... (artifact: 17bb7270ef user: stephan)
Context
2025-03-13
13:42
Fix typos in the main documentation page: althttpd.md. ... (Leaf check-in: 1f0dfc157e user: drh tags: trunk)
2025-02-20
15:12
Reenable restrictions on using less-secure TLS protocols. This breaks Fossil Chat and "fossil sync". ... (Closed-Leaf check-in: c25a278100 user: drh tags: no-tls1-attempt)
2025-01-24
13:15
Move the calculation of the request start time up to resolve problem where log writes can be sent to the wrong file when running in standalone server mode, as discussed in /forumpost/0e8dfd8d02bccd4a. ... (check-in: f6f3b8dd2d user: stephan tags: trunk)
2025-01-12
11:44
Improvements, including better instructions in the header comment, to the static-ssl.mk makefile. ... (check-in: f14e96c1b5 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to althttpd.c.
3019
3020
3021
3022
3023
3024
3025


3026
3027
3028
3029
3030
3031
3032
  FILE *hdrLog = 0;         /* Log file for complete header content */
#endif
  char zLine[10000];        /* A buffer for input lines or forming names */
  const MimeTypeDef *pMimeType = 0; /* URI's mimetype */
  size_t sz = 0;
  struct tm vTm;            /* Timestamp for zExpLogFile */



  if( zLogFile ){
    assert(beginTime.tv_sec > 0);
    gmtime_r(&beginTime.tv_sec, &vTm);
    sz = strftime(zExpLogFile, sizeof(zExpLogFile), zLogFile, &vTm);
  }
  if( sz==0 || sz>=sizeof(zExpLogFile)-2 ){
    /* Invalid zExpLogFile name */







>
>







3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
  FILE *hdrLog = 0;         /* Log file for complete header content */
#endif
  char zLine[10000];        /* A buffer for input lines or forming names */
  const MimeTypeDef *pMimeType = 0; /* URI's mimetype */
  size_t sz = 0;
  struct tm vTm;            /* Timestamp for zExpLogFile */

  clock_gettime(ALTHTTPD_CLOCK_ID, &tsBeginTime);
  gettimeofday(&beginTime, 0);
  if( zLogFile ){
    assert(beginTime.tv_sec > 0);
    gmtime_r(&beginTime.tv_sec, &vTm);
    sz = strftime(zExpLogFile, sizeof(zExpLogFile), zLogFile, &vTm);
  }
  if( sz==0 || sz>=sizeof(zExpLogFile)-2 ){
    /* Invalid zExpLogFile name */
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
  /* Get the first line of the request and parse out the
  ** method, the script and the protocol.
  */
  omitLog = 1;
  if( althttpd_fgets(zLine,sizeof(zLine),stdin)==0 ){
    althttpd_exit(0);
  }
  clock_gettime(ALTHTTPD_CLOCK_ID, &tsBeginTime);
  gettimeofday(&beginTime, 0);
  omitLog = 0;
  nIn += (i = (int)strlen(zLine));

  /* Parse the first line of the HTTP request */
  zMethod = StrDup(GetFirstElement(zLine,&z));
  zRealScript = zScript = StrDup(GetFirstElement(z,&z));
  zProtocol = StrDup(GetFirstElement(z,&z));







<
<







3059
3060
3061
3062
3063
3064
3065


3066
3067
3068
3069
3070
3071
3072
  /* Get the first line of the request and parse out the
  ** method, the script and the protocol.
  */
  omitLog = 1;
  if( althttpd_fgets(zLine,sizeof(zLine),stdin)==0 ){
    althttpd_exit(0);
  }


  omitLog = 0;
  nIn += (i = (int)strlen(zLine));

  /* Parse the first line of the HTTP request */
  zMethod = StrDup(GetFirstElement(zLine,&z));
  zRealScript = zScript = StrDup(GetFirstElement(z,&z));
  zProtocol = StrDup(GetFirstElement(z,&z));