couchbase 1.3.8-x64-mingw32 → 1.3.9-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3bdfb250955442247cc879213f3f7f0eb7c4351d
4
- data.tar.gz: 864471190b48d189d1bfc37b6bcc9f82fb1dec13
3
+ metadata.gz: df9e11b3246e5b4f24575b1075bf0fb7b7e661b5
4
+ data.tar.gz: deba9b0e6bb6fdb5f9236ba89324b060255305ce
5
5
  SHA512:
6
- metadata.gz: f5384d8ac193852e3a9744bcaf014a14fe828a7f3c4194d6bd40e642c1080968cbded951e6a67920c85471a4ddc80d92826b6b5164064d8cd8efd4f9cdfd1d0a
7
- data.tar.gz: 4621db3ca72a95baa32e090ef6855825c6c981cce661612d630cc59c9fb8c90b7b04f5334f7fbaf35ae81d649691bd84e1e69652a10ffef6af1361d4f95545e2
6
+ metadata.gz: 8c6ce70d4d7f98591c7a9856b44f730cf4b177b486fe7a67ad883d51dedddf95a8f05af0a67308ca4b2c29e2213d40b940fe5257407c07b3222c7cc200fc4f17
7
+ data.tar.gz: 49f7f6ca7db4d88e94efac86cb140bf411234f40e89a80a21644bc04a3e63d5fc609cc230a113d5f869f2922e16e05d9dfb53736045de78dd1599e527ed7d0d8
@@ -29,6 +29,25 @@ Couchbase's fork: https://github.com/couchbase/homebrew
29
29
 
30
30
  $ brew install https://raw.github.com/couchbase/homebrew/preview/Library/Formula/libcouchbase.rb
31
31
 
32
+ If you are experience issues with installing using system ruby, you
33
+ might try to use [rbenv][rbenv], and install couchbase there. Here are
34
+ the steps:
35
+
36
+ $ brew install rbenv ruby-build
37
+
38
+ Add the following line to the end of your .bashrc:
39
+
40
+ if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
41
+
42
+ Then install ruby and make it global:
43
+
44
+ $ rbenv install 2.1.2
45
+ $ rbenv global 2.1.2
46
+
47
+ Now you are ready to install and use couchbase ruby gem as usual:
48
+
49
+ $ gem install couchbase
50
+
32
51
  ### Debian (Ubuntu)
33
52
 
34
53
  Add the appropriate line to `/etc/apt/sources.list.d/couchbase.list` for
@@ -649,7 +668,7 @@ task and you will find all artifacts in `pkg/` directory:
649
668
  pkg/couchbase-1.3.4-x86-mingw32.gem
650
669
 
651
670
 
652
- [api]: http://www.couchbase.com/autodocs/couchbase-ruby-client-1.3.4/index.html
671
+ [api]: http://www.couchbase.com/autodocs/couchbase-ruby-client-latest/index.html
653
672
  [overview]: http://docs.couchbase.com/couchbase-sdk-ruby-1.3/index.html
654
673
  [1]: http://couchbase.com/issues/browse/RCBC
655
674
  [2]: http://freenode.net/irc_servers.shtml
@@ -662,4 +681,4 @@ task and you will find all artifacts in `pkg/` directory:
662
681
  [9]: http://rubygems.org/gems/eventmachine
663
682
  [10]: https://github.com/couchbase/couchbase-ruby-client/blob/master/CONTRIBUTING.markdown
664
683
  [11]: https://github.com/luislavena/rake-compiler
665
-
684
+ [rbenv]: https://github.com/sstephenson/rbenv#homebrew-on-mac-os-x
@@ -3,11 +3,15 @@
3
3
  This document is a list of user visible feature changes and important
4
4
  bugfixes. Do not forget to update this doc in every important patch.
5
5
 
6
+ ## 1.3.9 (2014-08-26)
7
+
8
+ * [major] Updates regarding libcouchbase 2.4.0. Deprecations cleanup
9
+
6
10
  ## 1.3.8 (2014-06-11)
7
11
 
8
12
  * [major] RCBC-176 Known Issue: When the couchbase client is used in
9
13
  an 'em-synchrony' context, it is possible that connection errors may
10
- not be propagated to the client. This leads to runtime assertion in
14
+ not be propagated to the client. This leads to runtime assertion in
11
15
  eventmachine.
12
16
 
13
17
  * [minor] Update runtime (connection_pool) and build (libcouchbase)
@@ -36,12 +36,12 @@ trigger_on_connect_callback(VALUE self)
36
36
  }
37
37
 
38
38
  static void
39
- error_callback(lcb_t handle, lcb_error_t error, const char *errinfo)
39
+ bootstrap_callback(lcb_t handle, lcb_error_t error)
40
40
  {
41
41
  struct cb_bucket_st *bucket = (struct cb_bucket_st *)lcb_get_cookie(handle);
42
42
 
43
43
  lcb_breakout(handle);
44
- bucket->exception = cb_check_error(error, errinfo, Qnil);
44
+ bucket->exception = cb_check_error(error, "bootstrap error", Qnil);
45
45
  if (bucket->async && !bucket->connected) {
46
46
  (void)trigger_on_connect_callback(bucket->self);
47
47
  }
@@ -407,7 +407,7 @@ do_connect(struct cb_bucket_st *bucket)
407
407
  rb_exc_raise(cb_check_error(err, "failed to create libcouchbase instance", Qnil));
408
408
  }
409
409
  lcb_set_cookie(bucket->handle, bucket);
410
- (void)lcb_set_error_callback(bucket->handle, error_callback);
410
+ (void)lcb_set_bootstrap_callback(bucket->handle, bootstrap_callback);
411
411
  (void)lcb_set_store_callback(bucket->handle, cb_storage_callback);
412
412
  (void)lcb_set_get_callback(bucket->handle, cb_get_callback);
413
413
  (void)lcb_set_touch_callback(bucket->handle, cb_touch_callback);
@@ -421,11 +421,8 @@ do_connect(struct cb_bucket_st *bucket)
421
421
  (void)lcb_set_unlock_callback(bucket->handle, cb_unlock_callback);
422
422
  (void)lcb_set_configuration_callback(bucket->handle, configuration_callback);
423
423
 
424
- if (bucket->timeout > 0) {
425
- lcb_set_timeout(bucket->handle, bucket->timeout);
426
- } else {
427
- bucket->timeout = lcb_get_timeout(bucket->handle);
428
- }
424
+ lcb_cntl(bucket->handle, (bucket->timeout > 0) ? LCB_CNTL_SET : LCB_CNTL_GET,
425
+ LCB_CNTL_OP_TIMEOUT, &bucket->timeout);
429
426
  err = lcb_connect(bucket->handle);
430
427
  if (err != LCB_SUCCESS) {
431
428
  cb_bucket_disconnect(bucket->self);
@@ -930,7 +927,7 @@ cb_bucket_timeout_set(VALUE self, VALUE val)
930
927
  VALUE tmval;
931
928
 
932
929
  bucket->timeout = (uint32_t)NUM2ULONG(val);
933
- lcb_set_timeout(bucket->handle, bucket->timeout);
930
+ lcb_cntl(bucket->handle, LCB_CNTL_SET, LCB_CNTL_OP_TIMEOUT, &bucket->timeout);
934
931
  tmval = ULONG2NUM(bucket->timeout);
935
932
 
936
933
  return tmval;
@@ -984,10 +981,15 @@ cb_bucket_key_prefix_set(VALUE self, VALUE val)
984
981
  cb_bucket_hostname_get(VALUE self)
985
982
  {
986
983
  struct cb_bucket_st *bucket = DATA_PTR(self);
987
-
988
984
  if (bucket->handle) {
989
- const char * host = lcb_get_host(bucket->handle);
990
- unsigned long len = RSTRING_LEN(bucket->hostname);
985
+ const char *host;
986
+ char *colon;
987
+ unsigned long len;
988
+ host = lcb_get_node(bucket->handle, LCB_NODE_HTCONFIG | LCB_NODE_NEVERNULL, 0);
989
+ if (host != NULL && (colon = strstr(host, ":")) != NULL) {
990
+ *colon = '\0';
991
+ }
992
+ len = RSTRING_LEN(bucket->hostname);
991
993
  if (len != strlen(host) || strncmp(RSTRING_PTR(bucket->hostname), host, len) != 0) {
992
994
  bucket->hostname = STR_NEW_CSTR(host);
993
995
  rb_str_freeze(bucket->hostname);
@@ -1007,7 +1009,12 @@ cb_bucket_port_get(VALUE self)
1007
1009
  {
1008
1010
  struct cb_bucket_st *bucket = DATA_PTR(self);
1009
1011
  if (bucket->handle) {
1010
- bucket->port = atoi(lcb_get_port(bucket->handle));
1012
+ const char *port;
1013
+ port = lcb_get_node(bucket->handle, LCB_NODE_HTCONFIG | LCB_NODE_NEVERNULL, 0);
1014
+ if (port && (port = strstr(port, ":"))) {
1015
+ port++;
1016
+ }
1017
+ bucket->port = atoi(port);
1011
1018
  }
1012
1019
  return UINT2NUM(bucket->port);
1013
1020
  }
@@ -1433,5 +1440,3 @@ cb_bucket_disconnect(VALUE self)
1433
1440
  return Qfalse;
1434
1441
  }
1435
1442
  }
1436
-
1437
-
@@ -38,7 +38,20 @@ typedef uint64_t hrtime_t;
38
38
  extern hrtime_t gethrtime(void);
39
39
  #endif
40
40
 
41
- #include <stdint.h>
41
+ #ifdef HAVE_SYS_SOCKET_H
42
+ #include <sys/socket.h>
43
+ #endif
44
+ #ifdef HAVE_FCNTL_H
45
+ #include <fcntl.h>
46
+ #endif
47
+ #ifdef HAVE_ERRNO_H
48
+ #include <errno.h>
49
+ #endif
50
+
51
+ #ifndef INVALID_SOCKET
52
+ #define INVALID_SOCKET -1
53
+ #endif
54
+
42
55
  #include <libcouchbase/couchbase.h>
43
56
 
44
57
  #ifdef HAVE_RUBY_ENCODING_H
@@ -645,4 +658,3 @@ rb_funcall_2(VALUE self, ID method, VALUE arg1, VALUE arg2)
645
658
  }
646
659
 
647
660
  #endif
648
-
@@ -20,7 +20,7 @@
20
20
  #ifndef _WIN32
21
21
  #ifdef BUILD_EVENTMACHINE_PLUGIN
22
22
 
23
- #include <errno.h>
23
+ #include <libcouchbase/bsdio-inl.c>
24
24
 
25
25
  VALUE cb_mEm;
26
26
  VALUE cb_cEmSocket;
@@ -433,13 +433,7 @@ cb_create_ruby_em_io_opts(int version, lcb_io_opt_t *io, void *arg)
433
433
  /* consider that struct isn't allocated by the library,
434
434
  * `need_cleanup' flag might be set in lcb_create() */
435
435
  ret->v.v0.need_cleanup = 0;
436
- ret->v.v0.recv = cb_io_recv;
437
- ret->v.v0.send = cb_io_send;
438
- ret->v.v0.recvv = cb_io_recvv;
439
- ret->v.v0.sendv = cb_io_sendv;
440
- ret->v.v0.socket = cb_io_socket;
441
- ret->v.v0.close = cb_io_close;
442
- ret->v.v0.connect = cb_io_connect;
436
+ wire_lcb_bsd_impl(ret);
443
437
  ret->v.v0.delete_event = lcb_io_delete_event;
444
438
  ret->v.v0.destroy_event = lcb_io_destroy_event;
445
439
  ret->v.v0.create_event = lcb_io_create_event;
@@ -132,7 +132,7 @@ def die(message)
132
132
  abort
133
133
  end
134
134
 
135
- install_notice = "You must install libcouchbase >= 2.3.0\nSee http://www.couchbase.com/communities/c/ for more details"
135
+ install_notice = "You must install libcouchbase >= 2.4.0\nSee http://www.couchbase.com/communities/c/ for more details"
136
136
 
137
137
  unless try_compile(<<-SRC)
138
138
  #include <libcouchbase/couchbase.h>
@@ -146,12 +146,39 @@ unless try_compile(<<-SRC)
146
146
  die(install_notice)
147
147
  end
148
148
 
149
+ unless 'foo()'.respond_to?(:funcall_style)
150
+ class String
151
+ def funcall_style
152
+ /\)\z/ =~ self ? dup : "#{self}()"
153
+ end
154
+ end
155
+
156
+ def try_func(func, libs, headers = nil, &b)
157
+ headers = cpp_include(headers)
158
+ try_link(<<"SRC", libs, &b) or try_link(<<"SRC", libs, &b)
159
+ #{COMMON_HEADERS}
160
+ #{headers}
161
+ /*top*/
162
+ int main() { return 0; }
163
+ int t() { void ((*volatile p)()); p = (void ((*)()))#{func}; return 0; }
164
+ SRC
165
+ #{headers}
166
+ /*top*/
167
+ int main() { return 0; }
168
+ int t() { #{func.funcall_style}; return 0; }
169
+ SRC
170
+ end
171
+ end
172
+
149
173
  # just to add -lcouchbase properly
150
- have_library("couchbase", "lcb_verify_compiler_setup", "libcouchbase/couchbase.h") or die(install_notice)
174
+ have_library("couchbase", "lcb_set_bootstrap_callback(NULL, NULL)", "libcouchbase/couchbase.h") or die(install_notice)
151
175
  have_header("mach/mach_time.h")
152
176
  have_header("stdint.h") or die("Failed to locate stdint.h")
153
177
  have_header("sys/time.h")
154
178
  have_header("fcntl.h")
179
+ have_header("sys/socket.h")
180
+ have_header("errno.h")
181
+
155
182
  have_type("st_index_t")
156
183
  have_func("clock_gettime")
157
184
  have_func("gettimeofday")
@@ -17,7 +17,6 @@
17
17
 
18
18
  #include "couchbase_ext.h"
19
19
 
20
-
21
20
  #ifndef _WIN32
22
21
 
23
22
  #ifndef HAVE_RB_THREAD_BLOCKING_REGION
@@ -28,6 +27,8 @@
28
27
  #include <poll.h>
29
28
  #endif
30
29
 
30
+ #include <libcouchbase/bsdio-inl.c>
31
+
31
32
  /* events sorted array */
32
33
  typedef struct rb_mt_event rb_mt_event;
33
34
  struct rb_mt_event {
@@ -1058,13 +1059,7 @@ cb_create_ruby_mt_io_opts(int version, lcb_io_opt_t *io, void *arg)
1058
1059
  /* consider that struct isn't allocated by the library,
1059
1060
  * `need_cleanup' flag might be set in lcb_create() */
1060
1061
  ret->v.v0.need_cleanup = 0;
1061
- ret->v.v0.recv = cb_io_recv;
1062
- ret->v.v0.send = cb_io_send;
1063
- ret->v.v0.recvv = cb_io_recvv;
1064
- ret->v.v0.sendv = cb_io_sendv;
1065
- ret->v.v0.socket = cb_io_socket;
1066
- ret->v.v0.close = cb_io_close;
1067
- ret->v.v0.connect = cb_io_connect;
1062
+ wire_lcb_bsd_impl(ret);
1068
1063
  ret->v.v0.delete_event = lcb_io_delete_event;
1069
1064
  ret->v.v0.destroy_event = lcb_io_destroy_event;
1070
1065
  ret->v.v0.create_event = lcb_io_create_event;
@@ -272,6 +272,13 @@ cb_check_error_with_status(lcb_error_t rc, const char *msg, VALUE key,
272
272
  }
273
273
 
274
274
  str = rb_str_buf_new2(msg ? msg : "");
275
+ if (msg) {
276
+ str = rb_str_buf_new2(msg);
277
+ rb_str_buf_cat2(str, ", ");
278
+ } else {
279
+ str = rb_str_buf_new2("");
280
+ }
281
+ rb_str_buf_cat2(str, lcb_strerror(NULL, rc));
275
282
  rb_str_buf_cat2(str, " (");
276
283
  if (key != Qnil) {
277
284
  snprintf(buf, 300, "key=\"%s\", ", RSTRING_PTR(key));
@@ -17,5 +17,5 @@
17
17
 
18
18
  # Couchbase ruby client
19
19
  module Couchbase
20
- VERSION = "1.3.8"
20
+ VERSION = "1.3.9"
21
21
  end
@@ -137,12 +137,13 @@ task "package:windows" => ["package", "lib/couchbase_ext.rb"] do
137
137
  ENV['TARGET'] = platform.name
138
138
  rm_rf("tmp/ ports/")
139
139
  mkdir_p("ports")
140
- recipe = MiniPortile.new("libcouchbase", "2.3.1")
140
+ recipe = MiniPortile.new("libcouchbase", "2.4.0_21_g879b4cd")
141
141
  recipe.host = platform.host
142
142
  recipe.files << "http://packages.couchbase.com/clients/c/libcouchbase-#{recipe.version}.tar.gz"
143
143
  recipe.configure_options.push("--disable-debug",
144
144
  "--disable-dependency-tracking",
145
145
  "--disable-couchbasemock",
146
+ "--enable-ssl=no",
146
147
  "--disable-cxx",
147
148
  "--disable-plugins",
148
149
  "--disable-examples",
@@ -19,7 +19,7 @@ require 'rake/testtask'
19
19
  require 'rake/clean'
20
20
 
21
21
  rule 'test/CouchbaseMock.jar' do |task|
22
- jar_path = "0.5-SNAPSHOT/CouchbaseMock-0.5-20120726.220757-19.jar"
22
+ jar_path = "0.8-SNAPSHOT/CouchbaseMock-0.8-20140621.030439-1.jar"
23
23
  sh %{wget -q -O test/CouchbaseMock.jar http://files.couchbase.com/maven2/org/couchbase/mock/CouchbaseMock/#{jar_path}}
24
24
  end
25
25
 
@@ -76,7 +76,7 @@ class TestBucket < MiniTest::Test
76
76
 
77
77
  def test_it_raises_network_error_if_server_not_found
78
78
  refute(`netstat -tnl` =~ /12345/)
79
- assert_raises Couchbase::Error::Connect do
79
+ assert_raises Couchbase::Error::Network do
80
80
  Couchbase.new(:port => 12345)
81
81
  end
82
82
  end
@@ -123,7 +123,7 @@ class TestBucket < MiniTest::Test
123
123
  :port => mock.port,
124
124
  :bucket => 'default',
125
125
  :password => 'wrong_password')
126
- end
126
+ end if mock.real?
127
127
  assert_raises Couchbase::Error::InvalidUsername do
128
128
  Couchbase.new(:hostname => mock.host,
129
129
  :port => mock.port,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.8
4
+ version: 1.3.9
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Couchbase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-11 00:00:00.000000000 Z
11
+ date: 2014-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yaji
@@ -245,7 +245,6 @@ files:
245
245
  - ext/couchbase_ext/http.c
246
246
  - ext/couchbase_ext/multithread_plugin.c
247
247
  - ext/couchbase_ext/observe.c
248
- - ext/couchbase_ext/plugin_common.c
249
248
  - ext/couchbase_ext/result.c
250
249
  - ext/couchbase_ext/stats.c
251
250
  - ext/couchbase_ext/store.c
@@ -257,6 +256,9 @@ files:
257
256
  - lib/action_dispatch/middleware/session/couchbase_store.rb
258
257
  - lib/active_support/cache/couchbase_store.rb
259
258
  - lib/couchbase.rb
259
+ - lib/couchbase/1.9/couchbase_ext.so
260
+ - lib/couchbase/2.0/couchbase_ext.so
261
+ - lib/couchbase/2.1/couchbase_ext.so
260
262
  - lib/couchbase/bucket.rb
261
263
  - lib/couchbase/cluster.rb
262
264
  - lib/couchbase/connection_pool.rb
@@ -268,6 +270,7 @@ files:
268
270
  - lib/couchbase/version.rb
269
271
  - lib/couchbase/view.rb
270
272
  - lib/couchbase/view_row.rb
273
+ - lib/couchbase_ext.rb
271
274
  - lib/ext/multi_json_fix.rb
272
275
  - lib/rack/session/couchbase.rb
273
276
  - tasks/benchmark.rake
@@ -297,10 +300,6 @@ files:
297
300
  - test/test_unlock.rb
298
301
  - test/test_utils.rb
299
302
  - test/test_version.rb
300
- - lib/couchbase/1.9/couchbase_ext.so
301
- - lib/couchbase/2.0/couchbase_ext.so
302
- - lib/couchbase/2.1/couchbase_ext.so
303
- - lib/couchbase_ext.rb
304
303
  homepage: http://couchbase.org
305
304
  licenses:
306
305
  - ASL-2
@@ -321,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
321
320
  version: '0'
322
321
  requirements: []
323
322
  rubyforge_project:
324
- rubygems_version: 2.0.14
323
+ rubygems_version: 2.3.0
325
324
  signing_key:
326
325
  specification_version: 4
327
326
  summary: Couchbase ruby driver
@@ -1,171 +0,0 @@
1
- /* vim: ft=c et ts=8 sts=4 sw=4 cino=
2
- *
3
- * Copyright 2012 Couchbase, Inc.
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- #include "couchbase_ext.h"
19
-
20
- #ifndef _WIN32
21
-
22
- #include <errno.h>
23
- #include <sys/types.h>
24
- #include <sys/socket.h>
25
-
26
- #ifndef RUBY_WIN32_H
27
- # include <unistd.h>
28
- #ifdef HAVE_FCNTL_H
29
- # include <fcntl.h>
30
- #endif
31
- #define INVALID_SOCKET (-1)
32
- #else /* RUBY_WIN32_h */
33
- static st_table *socket_2_fd = NULL;
34
- #endif
35
-
36
- /* Copied from libev plugin */
37
- lcb_ssize_t
38
- cb_io_recv(struct lcb_io_opt_st *iops, lcb_socket_t sock,
39
- void *buffer, lcb_size_t len, int flags)
40
- {
41
- lcb_ssize_t ret = recv(sock, buffer, len, flags);
42
- if (ret < 0) {
43
- iops->v.v0.error = errno;
44
- }
45
- return ret;
46
- }
47
-
48
- lcb_ssize_t
49
- cb_io_recvv(struct lcb_io_opt_st *iops, lcb_socket_t sock,
50
- struct lcb_iovec_st *iov, lcb_size_t niov)
51
- {
52
- struct msghdr msg;
53
- struct iovec vec[2];
54
- lcb_ssize_t ret;
55
-
56
- if (niov != 2) {
57
- return -1;
58
- }
59
- memset(&msg, 0, sizeof(msg));
60
- msg.msg_iov = vec;
61
- msg.msg_iovlen = iov[1].iov_len ? (lcb_size_t)2 : (lcb_size_t)1;
62
- msg.msg_iov[0].iov_base = iov[0].iov_base;
63
- msg.msg_iov[0].iov_len = iov[0].iov_len;
64
- msg.msg_iov[1].iov_base = iov[1].iov_base;
65
- msg.msg_iov[1].iov_len = iov[1].iov_len;
66
- ret = recvmsg(sock, &msg, 0);
67
-
68
- if (ret < 0) {
69
- iops->v.v0.error = errno;
70
- }
71
-
72
- return ret;
73
- }
74
-
75
- lcb_ssize_t
76
- cb_io_send(struct lcb_io_opt_st *iops, lcb_socket_t sock,
77
- const void *msg, lcb_size_t len, int flags)
78
- {
79
- lcb_ssize_t ret = send(sock, msg, len, flags);
80
- if (ret < 0) {
81
- iops->v.v0.error = errno;
82
- }
83
- return ret;
84
- }
85
-
86
- lcb_ssize_t
87
- cb_io_sendv(struct lcb_io_opt_st *iops, lcb_socket_t sock,
88
- struct lcb_iovec_st *iov, lcb_size_t niov)
89
- {
90
- struct msghdr msg;
91
- struct iovec vec[2];
92
- lcb_ssize_t ret;
93
-
94
- if (niov != 2) {
95
- return -1;
96
- }
97
- memset(&msg, 0, sizeof(msg));
98
- msg.msg_iov = vec;
99
- msg.msg_iovlen = iov[1].iov_len ? (lcb_size_t)2 : (lcb_size_t)1;
100
- msg.msg_iov[0].iov_base = iov[0].iov_base;
101
- msg.msg_iov[0].iov_len = iov[0].iov_len;
102
- msg.msg_iov[1].iov_base = iov[1].iov_base;
103
- msg.msg_iov[1].iov_len = iov[1].iov_len;
104
- ret = sendmsg(sock, &msg, 0);
105
-
106
- if (ret < 0) {
107
- iops->v.v0.error = errno;
108
- }
109
- return ret;
110
- }
111
-
112
- static int
113
- make_socket_nonblocking(lcb_socket_t sock)
114
- {
115
- int flags = 0;
116
- #ifdef F_GETFL
117
- if ((flags = fcntl(sock, F_GETFL, NULL)) < 0) {
118
- return -1;
119
- }
120
- #endif
121
- if (fcntl(sock, F_SETFL, flags | O_NONBLOCK) == -1) {
122
- return -1;
123
- }
124
-
125
- return 0;
126
- }
127
-
128
- static int
129
- close_socket(lcb_socket_t sock)
130
- {
131
- return close(sock);
132
- }
133
-
134
- lcb_socket_t
135
- cb_io_socket(struct lcb_io_opt_st *iops, int domain, int type,
136
- int protocol)
137
- {
138
- lcb_socket_t sock = socket(domain, type, protocol);
139
- if (sock == INVALID_SOCKET) {
140
- iops->v.v0.error = errno;
141
- } else {
142
- if (make_socket_nonblocking(sock) != 0) {
143
- int error = errno;
144
- iops->v.v0.close(iops, sock);
145
- iops->v.v0.error = error;
146
- sock = INVALID_SOCKET;
147
- }
148
- }
149
-
150
- return sock;
151
- }
152
-
153
- void
154
- cb_io_close(struct lcb_io_opt_st *iops, lcb_socket_t sock)
155
- {
156
- close_socket(sock);
157
- (void)iops;
158
- }
159
-
160
- int
161
- cb_io_connect(struct lcb_io_opt_st *iops, lcb_socket_t sock,
162
- const struct sockaddr *name, unsigned int namelen)
163
- {
164
- int ret = connect(sock, name, (socklen_t)namelen);
165
- if (ret < 0) {
166
- iops->v.v0.error = errno;
167
- }
168
- return ret;
169
- }
170
-
171
- #endif