Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Jul 2006 22:00:51 GMT
From:      Rauf Kuliyev <rauf@kuliyev.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/100893: Add kqueue(2) support to mysql41-server
Message-ID:  <200607262200.k6QM0pAL003468@www.freebsd.org>
Resent-Message-ID: <200607262210.k6QMAJK8047916@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         100893
>Category:       ports
>Synopsis:       Add kqueue(2) support to mysql41-server
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 26 22:10:18 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Rauf Kuliyev
>Release:        FreeBSD 6.1-RELEASE-p3
>Organization:
>Environment:
FreeBSD laptop.kuliyev.com 6.1-RELEASE-p3 FreeBSD 6.1-RELEASE-p3 #0: Mon Jul 10 11:56:26 AZST 2006     root@laptop.kuliyev.com:/usr/obj/usr/src/sys/C1110  i386
>Description:
Patch to support kqueue(2) to mysql 4.1.20 server port.
>How-To-Repeat:

>Fix:
diff -u -r databases/mysql41-server.orig/Makefile databases/mysql41-server/Makefile
--- databases/mysql41-server.orig/Makefile	Thu Jun 22 15:23:04 2006
+++ databases/mysql41-server/Makefile	Thu Jul 27 02:41:48 2006
@@ -59,6 +59,9 @@
 .if defined(WITH_COLLATION) && ${WITH_COLLATION} != ""
 CONFIGURE_ARGS+=--with-collation=${WITH_COLLATION}
 .endif
+.if defined(WITH_KQUEUE)
+CFLAGS+=-DWITH_KQUEUE
+.endif
 
 .include <bsd.port.pre.mk>
 
@@ -139,6 +142,7 @@
 	@${ECHO} "				(use it if you need even more speed)."
 	@${ECHO} "	WITHOUT_INNODB=yes	Disable support for InnoDB table handler."
 	@${ECHO} "	WITH_NDB=yes		Enable support for NDB Cluster."
+	@${ECHO} "	WITH_KQUEUE=yes		Enable support for kqueue(2)."
 	@${ECHO} ""
 
 post-patch:
diff -u -r databases/mysql41-server.orig/files/patch-sql::mysqld.cc databases/mysql41-server/files/patch-sql::mysqld.cc
--- databases/mysql41-server.orig/files/patch-sql::mysqld.cc	Sun Jan 16 14:24:46 2005
+++ databases/mysql41-server/files/patch-sql::mysqld.cc	Thu Jul 27 02:40:29 2006
@@ -1,6 +1,6 @@
---- sql/mysqld.cc.orig	Tue Dec 14 13:40:36 2004
-+++ sql/mysqld.cc	Mon Jan 10 00:28:52 2005
-@@ -128,7 +128,7 @@
+--- sql/mysqld.cc.orig	Wed May 24 22:59:52 2006
++++ sql/mysqld.cc	Thu Jul 27 02:18:31 2006
+@@ -133,7 +133,7 @@
  #endif /* __WIN__ */
  
  #ifdef HAVE_LIBWRAP
@@ -9,3 +9,90 @@
  #include <syslog.h>
  #ifdef NEED_SYS_SYSLOG_H
  #include <sys/syslog.h>
+@@ -151,6 +151,10 @@
+ #define zVOLSTATE_DEACTIVE 2
+ #define zVOLSTATE_MAINTENANCE 3
+ 
++#ifdef WITH_KQUEUE
++#include <sys/event.h>
++#endif
++
+ #ifdef __NETWARE__
+ #include <nks/netware.h>
+ #include <nks/vm.h>
+@@ -556,6 +560,10 @@
+ static unsigned long openssl_id_function();
+ #endif /* HAVE_OPENSSL */
+ 
++#ifdef WITH_KQUEUE
++int kq;
++struct kevent kev;
++#endif
+ 
+ /* Function declarations */
+ 
+@@ -3664,16 +3672,38 @@
+ 
+   (void) my_pthread_getprio(pthread_self());		// For debugging
+ 
+-  FD_ZERO(&clientFDs);
++#ifdef WITH_KQUEUE
++  if ((kq = kqueue()) <0) {
++    sql_print_error("mysqld: Could not get kqueue");
++  }
++#else
++   FD_ZERO(&clientFDs);
++#endif
++
+   if (ip_sock != INVALID_SOCKET)
+   {
+-    FD_SET(ip_sock,&clientFDs);
++#ifdef WITH_KQUEUE
++     EV_SET(&kev, ip_sock, EVFILT_READ, EV_ADD, 0, 0, NULL);
++     if ((kevent(kq, &kev, 1, NULL, 0, NULL)) <0)
++       sql_print_error("mysqld: ip_sock kevent registration error");
++#else
++     FD_SET(ip_sock,&clientFDs);
++#endif
++
+ #ifdef HAVE_FCNTL
+     ip_flags = fcntl(ip_sock, F_GETFL, 0);
+ #endif
+   }
+ #ifdef HAVE_SYS_UN_H
++#ifdef WITH_KQUEUE
++  EV_SET(&kev, unix_sock, EVFILT_READ, EV_ADD, 0, 0, NULL);
++  if ((kevent(kq, &kev, 1, NULL, 0, NULL)) <0) {
++    sql_print_error("mysqld: unix_sock kevent registration error");
++  }
++#else
+   FD_SET(unix_sock,&clientFDs);
++#endif /* WITH_KQUEUE */
++
+ #ifdef HAVE_FCNTL
+   socket_flags=fcntl(unix_sock, F_GETFL, 0);
+ #endif
+@@ -3688,7 +3718,11 @@
+     if (select(max_used_connection,(int*) &readFDs,0,0,0) < 0)
+       continue;
+ #else
++#ifdef WITH_KQUEUE
++    if (kevent(kq, NULL, 0, &kev, 1, 0) < 0)
++#else
+     if (select((int) max_used_connection,&readFDs,0,0,0) < 0)
++#endif
+     {
+       if (socket_errno != SOCKET_EINTR)
+       {
+@@ -3707,7 +3741,11 @@
+ 
+     /* Is this a new connection request ? */
+ #ifdef HAVE_SYS_UN_H
++#ifdef WITH_KQUEUE
++    if (kev.ident == unix_sock)
++#else
+     if (FD_ISSET(unix_sock,&readFDs))
++#endif /* WITH_KQUEUE */
+     {
+       sock = unix_sock;
+       flags= socket_flags;

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607262200.k6QM0pAL003468>