Re: Adding Rendezvous support to postmaster - Mailing list pgsql-patches
From | Bruce Momjian |
---|---|
Subject | Re: Adding Rendezvous support to postmaster |
Date | |
Msg-id | 200306110659.h5B6xnP11693@candle.pha.pa.us Whole thread Raw |
In response to | Adding Rendezvous support to postmaster (Chris Campbell <chris@bignerdranch.com>) |
Responses |
Re: Adding Rendezvous support to postmaster
|
List | pgsql-patches |
I have applied the attached Rendezvous patch. Per suggestion from Peter, a --with-rendezvous flag was added to configure. This is similar to the PAM flag we already have. I also _didn't_ add the Rendezvous GUC variable, so we default to the host name. If there is need, we can add it later. --------------------------------------------------------------------------- Chris Campbell wrote: > The attached diffs add Rendezvous support to postmaster when it's > running on Darwin (Mac OS X). > > Rendezvous allows services (such as a database server) to advertise > their availability to other hosts on their link-local network, and > client programs to browse the services on the network to see what's > available. It is Apple's implementation of ZEROCONF. > > http://developer.apple.com/macosx/rendezvous/ > > This allows client programs running on computers that are on the same > link-local network as the postgresql server to automatically find the > server's IP address and port number. This adds great ease-of-use for > end users. > > I propose adding a configuration variable to postgresql.conf called > "service_name" that allows the user to specify the name used to > advertise the database service. If this variable isn't defined in the > postgresql.conf file, then no service is advertised. If it is '', then > the computer's "Rendezvous Name" is used (this is similar to the > hostname, see the link below for more info). Otherwise, if it's a > non-empty string, that string is used as the name of the service. > > http://developer.apple.com/qa/qa2001/qa1228.html > > If there's already a service on the network with that name, then the > service registration silently fails and no service is registered. > > Rendezvous also has the notion of a service type string. It's a bit > like a domain name: I suggest we use "_pgsql._tcp." (another example > would be "_ftp._tcp."). > > There's very little code involved: just 1 function call in > PostmasterMain() after postmaster has started listening on a TCP > socket. And 1 addition to the GUC list of configuration variables. > > All the code is #ifdef'ed inside HAVE_RENDEZVOUS, which is only defined > in src/include/port/darwin.h. Even once we know the OS is darwin, we > still need to check to make sure that Rendezvous is available, either > by OS version, or by checking for the existence of a needed header > file, etc. > > I've included patches for CVS top-of-tree and postgresql-7.3.2. > > Thanks! > > - Chris > [ Attachment, skipping... ] [ Attachment, skipping... ] > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073 Index: configure =================================================================== RCS file: /cvsroot/pgsql-server/configure,v retrieving revision 1.266 diff -c -c -r1.266 configure *** configure 9 Jun 2003 03:41:47 -0000 1.266 --- configure 11 Jun 2003 06:31:31 -0000 *************** *** 866,871 **** --- 866,872 ---- --with-krb5[=DIR] build with Kerberos 5 support [/usr/athena] --with-krb-srvnam=NAME name of the service principal in Kerberos postgres --with-pam build with PAM support + --with-rendezvous build with Rendezvous support --with-openssl[=DIR] build with OpenSSL support [/usr/local/ssl] --without-readline do not use Readline --without-zlib do not use Zlib *************** *** 3361,3366 **** --- 3362,3407 ---- # + # Rendezvous + # + echo "$as_me:$LINENO: checking whether to build with Rendezvous support" >&5 + echo $ECHO_N "checking whether to build with Rendezvous support... $ECHO_C" >&6 + + + + # Check whether --with-rendezvous or --without-rendezvous was given. + if test "${with_rendezvous+set}" = set; then + withval="$with_rendezvous" + + case $withval in + yes) + + cat >>confdefs.h <<\_ACEOF + #define USE_RENDEZVOUS 1 + _ACEOF + + ;; + no) + : + ;; + *) + { { echo "$as_me:$LINENO: error: no argument expected for --with-rendezvous option" >&5 + echo "$as_me: error: no argument expected for --with-rendezvous option" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + else + with_rendezvous=no + + fi; + + echo "$as_me:$LINENO: result: $with_rendezvous" >&5 + echo "${ECHO_T}$with_rendezvous" >&6 + + + + # # OpenSSL # *************** *** 9040,9045 **** --- 9081,9199 ---- fi + if test "$with_rendezvous" = yes ; then + if test "${ac_cv_header_DNSServiceDiscovery_DNSServiceDiscovery_h+set}" = set; then + echo "$as_me:$LINENO: checking for DNSServiceDiscovery/DNSServiceDiscovery.h" >&5 + echo $ECHO_N "checking for DNSServiceDiscovery/DNSServiceDiscovery.h... $ECHO_C" >&6 + if test "${ac_cv_header_DNSServiceDiscovery_DNSServiceDiscovery_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 + fi + echo "$as_me:$LINENO: result: $ac_cv_header_DNSServiceDiscovery_DNSServiceDiscovery_h" >&5 + echo "${ECHO_T}$ac_cv_header_DNSServiceDiscovery_DNSServiceDiscovery_h" >&6 + else + # Is the header compilable? + echo "$as_me:$LINENO: checking DNSServiceDiscovery/DNSServiceDiscovery.h usability" >&5 + echo $ECHO_N "checking DNSServiceDiscovery/DNSServiceDiscovery.h usability... $ECHO_C" >&6 + cat >conftest.$ac_ext <<_ACEOF + #line $LINENO "configure" + #include "confdefs.h" + $ac_includes_default + #include <DNSServiceDiscovery/DNSServiceDiscovery.h> + _ACEOF + rm -f conftest.$ac_objext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes + else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_compiler=no + fi + rm -f conftest.$ac_objext conftest.$ac_ext + echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 + echo "${ECHO_T}$ac_header_compiler" >&6 + + # Is the header present? + echo "$as_me:$LINENO: checking DNSServiceDiscovery/DNSServiceDiscovery.h presence" >&5 + echo $ECHO_N "checking DNSServiceDiscovery/DNSServiceDiscovery.h presence... $ECHO_C" >&6 + cat >conftest.$ac_ext <<_ACEOF + #line $LINENO "configure" + #include "confdefs.h" + #include <DNSServiceDiscovery/DNSServiceDiscovery.h> + _ACEOF + if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + egrep -v '^ *\+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi + else + ac_cpp_err=yes + fi + if test -z "$ac_cpp_err"; then + ac_header_preproc=yes + else + echo "$as_me: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_header_preproc=no + fi + rm -f conftest.err conftest.$ac_ext + echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 + echo "${ECHO_T}$ac_header_preproc" >&6 + + # So? What about this header? + case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: DNSServiceDiscovery/DNSServiceDiscovery.h: accepted by the compiler, rejected by thepreprocessor!" >&5 + echo "$as_me: WARNING: DNSServiceDiscovery/DNSServiceDiscovery.h: accepted by the compiler, rejected by the preprocessor!">&2;} + { echo "$as_me:$LINENO: WARNING: DNSServiceDiscovery/DNSServiceDiscovery.h: proceeding with the preprocessor's result">&5 + echo "$as_me: WARNING: DNSServiceDiscovery/DNSServiceDiscovery.h: proceeding with the preprocessor's result" >&2;};; + no:yes ) + { echo "$as_me:$LINENO: WARNING: DNSServiceDiscovery/DNSServiceDiscovery.h: present but cannot be compiled" >&5 + echo "$as_me: WARNING: DNSServiceDiscovery/DNSServiceDiscovery.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: DNSServiceDiscovery/DNSServiceDiscovery.h: check for missing prerequisite headers?">&5 + echo "$as_me: WARNING: DNSServiceDiscovery/DNSServiceDiscovery.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: DNSServiceDiscovery/DNSServiceDiscovery.h: proceeding with the preprocessor's result">&5 + echo "$as_me: WARNING: DNSServiceDiscovery/DNSServiceDiscovery.h: proceeding with the preprocessor's result" >&2;};; + esac + echo "$as_me:$LINENO: checking for DNSServiceDiscovery/DNSServiceDiscovery.h" >&5 + echo $ECHO_N "checking for DNSServiceDiscovery/DNSServiceDiscovery.h... $ECHO_C" >&6 + if test "${ac_cv_header_DNSServiceDiscovery_DNSServiceDiscovery_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 + else + ac_cv_header_DNSServiceDiscovery_DNSServiceDiscovery_h=$ac_header_preproc + fi + echo "$as_me:$LINENO: result: $ac_cv_header_DNSServiceDiscovery_DNSServiceDiscovery_h" >&5 + echo "${ECHO_T}$ac_cv_header_DNSServiceDiscovery_DNSServiceDiscovery_h" >&6 + + fi + if test $ac_cv_header_DNSServiceDiscovery_DNSServiceDiscovery_h = yes; then + : + else + { { echo "$as_me:$LINENO: error: header file <DNSServiceDiscovery/DNSServiceDiscovery.h> is required for Rendezvous">&5 + echo "$as_me: error: header file <DNSServiceDiscovery/DNSServiceDiscovery.h> is required for Rendezvous" >&2;} + { (exit 1); exit 1; }; } + fi + + + fi + ## ## Types, structures, compiler characteristics *************** *** 17327,17332 **** --- 17481,17487 ---- s,@with_krb5@,$with_krb5,;t t s,@krb_srvtab@,$krb_srvtab,;t t s,@with_pam@,$with_pam,;t t + s,@with_rendezvous@,$with_rendezvous,;t t s,@with_openssl@,$with_openssl,;t t s,@ELF_SYS@,$ELF_SYS,;t t s,@THREAD_LIBS@,$THREAD_LIBS,;t t Index: configure.in =================================================================== RCS file: /cvsroot/pgsql-server/configure.in,v retrieving revision 1.257 diff -c -c -r1.257 configure.in *** configure.in 9 Jun 2003 03:41:46 -0000 1.257 --- configure.in 11 Jun 2003 06:31:33 -0000 *************** *** 472,477 **** --- 472,488 ---- # + # Rendezvous + # + AC_MSG_CHECKING([whether to build with Rendezvous support]) + PGAC_ARG_BOOL(with, rendezvous, no, + [ --with-rendezvous build with Rendezvous support], + [AC_DEFINE([USE_RENDEZVOUS], 1, [Define to 1 to build with Rendezvous support. (--with-rendezvous)])]) + AC_MSG_RESULT([$with_rendezvous]) + AC_SUBST(with_rendezvous) + + + # # OpenSSL # PGAC_ARG_OPTARG(with, openssl, *************** *** 757,762 **** --- 768,777 ---- AC_CHECK_HEADERS(security/pam_appl.h, [], [AC_CHECK_HEADERS(pam/pam_appl.h, [], [AC_MSG_ERROR([header file <security/pam_appl.h> or <pam/pam_appl.h> is required forPAM.])])]) + fi + + if test "$with_rendezvous" = yes ; then + AC_CHECK_HEADER(DNSServiceDiscovery/DNSServiceDiscovery.h, [], [AC_MSG_ERROR([header file <DNSServiceDiscovery/DNSServiceDiscovery.h>is required for Rendezvous])]) fi Index: doc/src/sgml/installation.sgml =================================================================== RCS file: /cvsroot/pgsql-server/doc/src/sgml/installation.sgml,v retrieving revision 1.132 diff -c -c -r1.132 installation.sgml *** doc/src/sgml/installation.sgml 25 Mar 2003 16:15:36 -0000 1.132 --- doc/src/sgml/installation.sgml 11 Jun 2003 06:31:37 -0000 *************** *** 270,277 **** <listitem> <para> <application>Kerberos</>, <application>OpenSSL</>, or <application>PAM</>, ! if you want to support ! authentication using these services. </para> </listitem> </itemizedlist> --- 270,276 ---- <listitem> <para> <application>Kerberos</>, <application>OpenSSL</>, or <application>PAM</>, ! if you want to support authentication using these services. </para> </listitem> </itemizedlist> *************** *** 902,907 **** --- 901,915 ---- Prevents the use of the <application>Readline</> library. This disables command-line editing and history in <application>psql</application>, so it is not recommended. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term><option>--with-rendezvous</option></term> + <listitem> + <para> + Build with Rendezvous support. </para> </listitem> </varlistentry> Index: src/backend/postmaster/postmaster.c =================================================================== RCS file: /cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v retrieving revision 1.331 diff -c -c -r1.331 postmaster.c *** src/backend/postmaster/postmaster.c 28 May 2003 19:36:28 -0000 1.331 --- src/backend/postmaster/postmaster.c 11 Jun 2003 06:31:47 -0000 *************** *** 85,90 **** --- 85,94 ---- #include <getopt.h> #endif + #ifdef USE_RENDEZVOUS + #include <DNSServiceDiscovery/DNSServiceDiscovery.h> + #endif + #include "catalog/pg_database.h" #include "commands/async.h" #include "lib/dllist.h" *************** *** 366,371 **** --- 370,386 ---- } + #ifdef USE_RENDEZVOUS + + /* reg_reply -- empty callback function for DNSServiceRegistrationCreate() */ + static void + reg_reply(DNSServiceRegistrationReplyErrorType errorCode, void *context) + { + + } + + #endif + int PostmasterMain(int argc, char *argv[]) { *************** *** 723,728 **** --- 738,755 ---- else elog(LOG, "IPv4 socket created"); } + #endif + #ifdef USE_RENDEZVOUS + if (service_name != NULL) + { + DNSServiceRegistrationCreate(NULL, /* default to hostname */ + "_postgresql._tcp.", + "", + htonl(PostPortNumber), + "", + (DNSServiceRegistrationReply)reg_reply, + NULL); + } #endif } Index: src/include/pg_config.h.in =================================================================== RCS file: /cvsroot/pgsql-server/src/include/pg_config.h.in,v retrieving revision 1.48 diff -c -c -r1.48 pg_config.h.in *** src/include/pg_config.h.in 27 May 2003 16:36:50 -0000 1.48 --- src/include/pg_config.h.in 11 Jun 2003 06:31:49 -0000 *************** *** 564,569 **** --- 564,572 ---- /* Define to 1 to build with PAM support. (--with-pam) */ #undef USE_PAM + /* Define to 1 to build with Rendezvous support. (--with-rendezvous) */ + #undef USE_RENDEZVOUS + /* Define to build with (Open)SSL support. (--with-openssl) */ #undef USE_SSL
pgsql-patches by date: