Skip to content
Browse files

Move win32 iofactory into the same file

This makes it easier to remember to update that file when
we add support for more stuff. We should update the win32
plugin to allow extra dll's to be loaded as well..

Change-Id: Idad6c628a26a8d98fa876ef59a4a93e823337dc4
Reviewed-on: http://review.couchbase.org/21298
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
  • Loading branch information...
1 parent 2aeb9aa commit 70819fa67642b7e0754a54be96b90139572562b8 @trondn trondn committed with avsej Oct 3, 2012
Showing with 43 additions and 50 deletions.
  1. +1 −2 Makefile.am
  2. +1 −1 NMakefile
  3. +1 −1 configure.ac
  4. +4 −0 src/config_static.h
  5. +36 −1 src/iofactory.c
  6. +0 −45 src/iofactory_win32.c
View
3 Makefile.am
@@ -138,7 +138,7 @@ endif
if HAVE_WINSOCK2
if !HAVE_LIBEVENT
-libcouchbase_la_SOURCES += plugins/io/win32/plugin-win32.c src/iofactory_win32.c
+libcouchbase_la_SOURCES += plugins/io/win32/plugin-win32.c
libcouchbase_la_CPPFLAGS += -Iwin32 -Iplugins/io/win32
endif
else
@@ -366,7 +366,6 @@ EXTRA_DIST = \
include/memcached/COPYING \
include/memcached/README \
include/ep-engine/README \
- src/iofactory_win32.c \
contrib/libvbucket/rfc1321 \
tests/start_mock.sh \
win32
View
2 NMakefile
@@ -30,7 +30,7 @@ example_PROGRAMS = example\pillowfight\pillowfight.exe
libcouchbase_SOURCES = src\arithmetic.c src\base64.c src\behavior.c \
src\cookie.c src\error.c src\event.c src\flush.c src\get.c \
- src\handler.c src\instance.c src\iofactory_win32.c src\packet.c \
+ src\handler.c src\instance.c src\iofactory.c src\packet.c \
src\remove.c src\ringbuffer.c src\hashset.c src\server.c src\stats.c \
src\store.c src\strerror.c src\synchandler.c \
src\timeout.c src\timings.c src\touch.c src\utilities.c \
View
2 configure.ac
@@ -178,7 +178,7 @@ AC_ARG_WITH([couchbasemock],
AC_CHECK_HEADERS_ONCE([mach/mach_time.h sys/socket.h sys/time.h
netinet/in.h inttypes.h netdb.h unistd.h
ws2tcpip.h winsock2.h event.h stdint.h
- sys/uio.h sys/types.h fcntl.h])
+ sys/uio.h sys/types.h fcntl.h dlfcn.h])
AS_IF([test "x$ac_cv_header_stdint_h" != "xyes"],
[AC_MSG_ERROR(Failed to locate stdint.h)])
View
4 src/config_static.h
@@ -86,6 +86,10 @@
#include <fcntl.h>
#endif
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
#ifdef _WIN32
#include "win32/win_errno_sock.h"
typedef int ssize_t;
View
37 src/iofactory.c
@@ -16,7 +16,40 @@
*/
#include "internal.h"
-#include <dlfcn.h>
+
+#ifdef WIN32
+/*
+ * For windows we're currently only supporting the single IO method
+ * bundle.
+ */
+#include "winsock_io_opts.h"
+
+LIBCOUCHBASE_API
+lcb_error_t lcb_create_io_ops(lcb_io_opt_t *io,
+ const struct lcb_create_io_ops_st *options)
+{
+ lcb_error_t ret = LCB_SUCCESS;
+ lcb_io_ops_type_t type = LCB_IO_OPS_DEFAULT;
+
+ if (options != NULL) {
+ if (options->version != 0) {
+ return LCB_EINVAL;
+ }
+ type = options->v.v0.type;
+ }
+
+ if (type == LCB_IO_OPS_DEFAULT || type == LCB_IO_OPS_WINSOCK) {
+ *io = lcb_create_winsock_io_opts();
+ if (*io == NULL) {
+ return LCB_CLIENT_ENOMEM;
+ }
+ } else {
+ return LCB_NOT_SUPPORTED;
+ }
+
+ return LCB_SUCCESS;
+}
+#else
typedef lcb_io_opt_t (*create_func)(struct event_base *base);
typedef lcb_error_t (*create_v1_func)(lcb_io_opt_t *io, const void *cookie);
@@ -181,3 +214,5 @@ static lcb_error_t create_v1(lcb_io_opt_t *io,
return LCB_SUCCESS;
}
+
+#endif
View
45 src/iofactory_win32.c
@@ -1,45 +0,0 @@
-/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/*
- * Copyright 2011 Couchbase, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "internal.h"
-#include "winsock_io_opts.h"
-
-LIBCOUCHBASE_API
-lcb_error_t lcb_create_io_ops(lcb_io_opt_t *io,
- const struct lcb_create_io_ops_st *options)
-{
- lcb_error_t ret = LCB_SUCCESS;
- lcb_io_ops_type_t type = LCB_IO_OPS_DEFAULT;
-
- if (options != NULL) {
- if (options->version != 0) {
- return LCB_EINVAL;
- }
- type = options->v.v0.type;
- }
-
- if (type == LCB_IO_OPS_DEFAULT || type == LCB_IO_OPS_WINSOCK) {
- *io = lcb_create_winsock_io_opts();
- if (*io == NULL) {
- return LCB_CLIENT_ENOMEM;
- }
- } else {
- return LCB_NOT_SUPPORTED;
- }
-
- return LCB_SUCCESS;
-}

0 comments on commit 70819fa

Please sign in to comment.
Something went wrong with that request. Please try again.