Fossil

Check-in [0eeaa6224c]
Login

Check-in [0eeaa6224c]

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

Overview
Comment:Enhance the socket listener logic on unix so that it makes sure the IPV6_V6ONLY socket option is disabled, as we are told that this option is enabled by default on FreeBSD.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0eeaa6224cdbdbda632c5422d98aedd66603ec8bbbe1e11ea3f6b10f18f27e83
User & Date: drh 2025-04-16 10:20:04.280
References
2025-04-16
14:31
Fix [0eeaa6224cdbdbda] so that it compiles on Windows. [forum:/forumpost/3fc7aad2a3|Forum post 3fc7aad2a3]. ... (check-in: ccb4168616 user: drh tags: trunk)
Context
2025-04-16
11:40
Add the test/fake-smtpd.tcl script used for testing. It will likely come in handy someday. See header comments on the file for details. ... (check-in: f031f744f0 user: drh tags: trunk)
10:20
Enhance the socket listener logic on unix so that it makes sure the IPV6_V6ONLY socket option is disabled, as we are told that this option is enabled by default on FreeBSD. ... (check-in: 0eeaa6224c user: drh tags: trunk)
00:58
Break out SMTP faults as a separate category on the Error Log. ... (check-in: 2d3ace5a9f user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/cgi.c.
2496
2497
2498
2499
2500
2501
2502
















2503
2504
2505
2506
2507
2508
2509
    nHdr -= m+1;
  }
  fossil_free(zToFree);
  fgetc(g.httpIn);  /* Read past the "," separating header from content */
  cgi_init();
}


















#if INTERFACE
/*
** Bitmap values for the flags parameter to cgi_http_server().
*/
#define HTTP_SERVER_LOCALHOST      0x0001     /* Bind to 127.0.0.1 only */
#define HTTP_SERVER_SCGI           0x0002     /* SCGI instead of HTTP */







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
    nHdr -= m+1;
  }
  fossil_free(zToFree);
  fgetc(g.httpIn);  /* Read past the "," separating header from content */
  cgi_init();
}

/*
** Change the listening socket, if necessary, so that it will accept both IPv4
** and IPv6
*/
static void allowBothIpV4andV6(int listener){
#if defined(IPV6_V6ONLY)
  int ipv6only = -1;
  socklen_t ipv6only_size = sizeof(ipv6only);
  getsockopt(listener, IPPROTO_IPV6, IPV6_V6ONLY, &ipv6only, &ipv6only_size);
  if( ipv6only ){
    ipv6only = 0;
    setsockopt(listener, IPPROTO_IPV6, IPV6_V6ONLY, &ipv6only, ipv6only_size);
  }
#endif /* defined(IPV6_ONLY) */
}


#if INTERFACE
/*
** Bitmap values for the flags parameter to cgi_http_server().
*/
#define HTTP_SERVER_LOCALHOST      0x0001     /* Bind to 127.0.0.1 only */
#define HTTP_SERVER_SCGI           0x0002     /* SCGI instead of HTTP */
2623
2624
2625
2626
2627
2628
2629

2630
2631
2632
2633
2634
2635
2636
      }
      inaddr.sin6_port = htons(iPort);
      listener = socket(AF_INET6, SOCK_STREAM, 0);
      if( listener<0 ){
        iPort++;
        continue;
      }

    }

    /* if we can't terminate nicely, at least allow the socket to be reused */
    setsockopt(listener,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt));
  
    if( flags & HTTP_SERVER_UNIXSOCKET ){
      rc = bind(listener, (struct sockaddr*)&uxaddr, sizeof(uxaddr));







>







2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
      }
      inaddr.sin6_port = htons(iPort);
      listener = socket(AF_INET6, SOCK_STREAM, 0);
      if( listener<0 ){
        iPort++;
        continue;
      }
      allowBothIpV4andV6(listener);
    }

    /* if we can't terminate nicely, at least allow the socket to be reused */
    setsockopt(listener,SOL_SOCKET,SO_REUSEADDR,&opt,sizeof(opt));
  
    if( flags & HTTP_SERVER_UNIXSOCKET ){
      rc = bind(listener, (struct sockaddr*)&uxaddr, sizeof(uxaddr));