eventmachine 1.0.1-x86-mingw32 → 1.0.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.2 (March 8, 2013)
4
+ * binary win32 gems now include fastfilereader shim [#222]
5
+ * fix long-standing connection timeout issues [27fdd5b, igrigorik/em-http-request#222]
6
+ * http and line protocol cleanups [#193, #151]
7
+ * reactor return value cleanup [#225]
8
+ * fix double require from gemspec [#284]
9
+ * fix smtp server reset behavior [#351]
10
+ * fix EM.system argument handling [#322]
11
+ * ruby 1.9 compat in smtp server and stomp protocols [#349, #315]
12
+ * fix pause from post_init [#380]
13
+
3
14
  ## 1.0.1 (February 27, 2013)
4
- * use rb_wait_for_single_fd() on ruby 2.0 to fix rb_thread_select() deprecation
15
+ * use rb_wait_for_single_fd() on ruby 2.0 to fix rb_thread_select() deprecation [#363]
5
16
  * fix epoll/kqueue mode in ruby 2.0 by removing calls to rb_enable_interrupt() [#248, #389]
6
17
  * fix memory leak when verifying ssl cerificates [#403]
7
18
  * fix initial connection delay [#393, #374]
19
+ * fix build on windows [#371]
@@ -1,5 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/em/version', __FILE__)
2
+ $:.unshift File.expand_path("../lib", __FILE__)
3
+ require "em/version"
4
+
3
5
 
4
6
  Gem::Specification.new do |s|
5
7
  s.name = 'eventmachine'
@@ -15,7 +17,7 @@ Gem::Specification.new do |s|
15
17
 
16
18
  s.add_development_dependency 'rake-compiler', '~> 0.8.3'
17
19
  s.add_development_dependency 'yard', ">= 0.8.5.2"
18
- s.add_development_dependency 'bluecloth'
20
+ s.add_development_dependency 'bluecloth' unless RUBY_PLATFORM =~ /java/
19
21
 
20
22
  s.summary = 'Ruby/EventMachine library'
21
23
  s.description = "EventMachine implements a fast, single-threaded engine for arbitrary network
data/ext/ed.cpp CHANGED
@@ -460,8 +460,7 @@ ConnectionDescriptor::SetConnectPending
460
460
  void ConnectionDescriptor::SetConnectPending(bool f)
461
461
  {
462
462
  bConnectPending = f;
463
- if (f == false && NextHeartbeat)
464
- MyEventMachine->ClearHeartbeat(NextHeartbeat, this);
463
+ MyEventMachine->QueueHeartbeat(this);
465
464
  _UpdateEvents();
466
465
  }
467
466
 
@@ -1447,14 +1446,16 @@ void AcceptorDescriptor::Read()
1447
1446
  (*EventCallback) (GetBinding(), EM_CONNECTION_ACCEPTED, NULL, cd->GetBinding());
1448
1447
  }
1449
1448
  #ifdef HAVE_EPOLL
1450
- cd->GetEpollEvent()->events = EPOLLIN | (cd->SelectForWrite() ? EPOLLOUT : 0);
1449
+ cd->GetEpollEvent()->events =
1450
+ (cd->SelectForRead() ? EPOLLIN : 0) | (cd->SelectForWrite() ? EPOLLOUT : 0);
1451
1451
  #endif
1452
1452
  assert (MyEventMachine);
1453
1453
  MyEventMachine->Add (cd);
1454
1454
  #ifdef HAVE_KQUEUE
1455
1455
  if (cd->SelectForWrite())
1456
1456
  MyEventMachine->ArmKqueueWriter (cd);
1457
- MyEventMachine->ArmKqueueReader (cd);
1457
+ if (cd->SelectForRead())
1458
+ MyEventMachine->ArmKqueueReader (cd);
1458
1459
  #endif
1459
1460
  }
1460
1461
 
data/ext/em.cpp CHANGED
@@ -482,8 +482,7 @@ void EventMachine_t::Run()
482
482
  _AddNewDescriptors();
483
483
  _ModifyDescriptors();
484
484
 
485
- if (!_RunOnce())
486
- break;
485
+ _RunOnce();
487
486
  if (bTerminateSignalReceived)
488
487
  break;
489
488
  }
@@ -494,27 +493,24 @@ void EventMachine_t::Run()
494
493
  EventMachine_t::_RunOnce
495
494
  ************************/
496
495
 
497
- bool EventMachine_t::_RunOnce()
496
+ void EventMachine_t::_RunOnce()
498
497
  {
499
- bool ret;
500
498
  if (bEpoll)
501
- ret = _RunEpollOnce();
499
+ _RunEpollOnce();
502
500
  else if (bKqueue)
503
- ret = _RunKqueueOnce();
501
+ _RunKqueueOnce();
504
502
  else
505
- ret = _RunSelectOnce();
503
+ _RunSelectOnce();
506
504
  _DispatchHeartbeats();
507
505
  _CleanupSockets();
508
- return ret;
509
506
  }
510
507
 
511
508
 
512
-
513
509
  /*****************************
514
510
  EventMachine_t::_RunEpollOnce
515
511
  *****************************/
516
512
 
517
- bool EventMachine_t::_RunEpollOnce()
513
+ void EventMachine_t::_RunEpollOnce()
518
514
  {
519
515
  #ifdef HAVE_EPOLL
520
516
  assert (epfd != -1);
@@ -539,7 +535,7 @@ bool EventMachine_t::_RunEpollOnce()
539
535
  assert(errno != EINVAL);
540
536
  assert(errno != EBADF);
541
537
  }
542
- return true;
538
+ return;
543
539
  }
544
540
 
545
541
  TRAP_BEG;
@@ -577,8 +573,6 @@ bool EventMachine_t::_RunEpollOnce()
577
573
  timeval tv = {0, ((errno == EINTR) ? 5 : 50) * 1000};
578
574
  EmSelect (0, NULL, NULL, NULL, &tv);
579
575
  }
580
-
581
- return true;
582
576
  #else
583
577
  throw std::runtime_error ("epoll is not implemented on this platform");
584
578
  #endif
@@ -589,7 +583,7 @@ bool EventMachine_t::_RunEpollOnce()
589
583
  EventMachine_t::_RunKqueueOnce
590
584
  ******************************/
591
585
 
592
- bool EventMachine_t::_RunKqueueOnce()
586
+ void EventMachine_t::_RunKqueueOnce()
593
587
  {
594
588
  #ifdef HAVE_KQUEUE
595
589
  assert (kqfd != -1);
@@ -618,7 +612,7 @@ bool EventMachine_t::_RunKqueueOnce()
618
612
  assert(errno != EINVAL);
619
613
  assert(errno != EBADF);
620
614
  }
621
- return true;
615
+ return;
622
616
  }
623
617
 
624
618
  TRAP_BEG;
@@ -669,8 +663,6 @@ bool EventMachine_t::_RunKqueueOnce()
669
663
  rb_thread_schedule();
670
664
  }
671
665
  #endif
672
-
673
- return true;
674
666
  #else
675
667
  throw std::runtime_error ("kqueue is not implemented on this platform");
676
668
  #endif
@@ -843,37 +835,17 @@ int SelectData_t::_Select()
843
835
  EventMachine_t::_RunSelectOnce
844
836
  ******************************/
845
837
 
846
- bool EventMachine_t::_RunSelectOnce()
838
+ void EventMachine_t::_RunSelectOnce()
847
839
  {
848
840
  // Crank the event machine once.
849
841
  // If there are no descriptors to process, then sleep
850
842
  // for a few hundred mills to avoid busy-looping.
851
- // Return T/F to indicate whether we should continue.
852
843
  // This is based on a select loop. Alternately provide epoll
853
844
  // if we know we're running on a 2.6 kernel.
854
845
  // epoll will be effective if we provide it as an alternative,
855
846
  // however it has the same problem interoperating with Ruby
856
847
  // threads that select does.
857
848
 
858
- //cerr << "X";
859
-
860
- /* This protection is now obsolete, because we will ALWAYS
861
- * have at least one descriptor (the loop-breaker) to read.
862
- */
863
- /*
864
- if (Descriptors.size() == 0) {
865
- #ifdef OS_UNIX
866
- timeval tv = {0, 200 * 1000};
867
- EmSelect (0, NULL, NULL, NULL, &tv);
868
- return true;
869
- #endif
870
- #ifdef OS_WIN32
871
- Sleep (200);
872
- return true;
873
- #endif
874
- }
875
- */
876
-
877
849
  SelectData_t SelectData;
878
850
  /*
879
851
  fd_set fdreads, fdwrites;
@@ -975,8 +947,6 @@ bool EventMachine_t::_RunSelectOnce()
975
947
  }
976
948
  }
977
949
  }
978
-
979
- return true;
980
950
  }
981
951
 
982
952
  void EventMachine_t::_CleanBadDescriptors()
data/ext/em.h CHANGED
@@ -145,7 +145,7 @@ class EventMachine_t
145
145
  uint64_t GetRealTime();
146
146
 
147
147
  private:
148
- bool _RunOnce();
148
+ void _RunOnce();
149
149
  void _RunTimers();
150
150
  void _UpdateTime();
151
151
  void _AddNewDescriptors();
@@ -153,9 +153,9 @@ class EventMachine_t
153
153
  void _InitializeLoopBreaker();
154
154
  void _CleanupSockets();
155
155
 
156
- bool _RunSelectOnce();
157
- bool _RunEpollOnce();
158
- bool _RunKqueueOnce();
156
+ void _RunSelectOnce();
157
+ void _RunEpollOnce();
158
+ void _RunKqueueOnce();
159
159
 
160
160
  void _ModifyEpollEvent (EventableDescriptor*);
161
161
  void _DispatchHeartbeats();
@@ -114,7 +114,7 @@ module EventMachine
114
114
  init = args.pop if args.last.is_a? Proc
115
115
 
116
116
  # merge remaining arguments into the command
117
- cmd = ([cmd] + args.map{|a|a.to_s.dump}).join(' ')
117
+ cmd = [cmd, *args]
118
118
 
119
119
  EM.get_subprocess_pid(EM.popen(cmd, SystemCmd, cb) do |c|
120
120
  init[c] if init
@@ -32,5 +32,6 @@ module EventMachine
32
32
  autoload :Postgres3, 'em/protocols/postgres3'
33
33
  autoload :ObjectProtocol, 'em/protocols/object_protocol'
34
34
  autoload :Socks4, 'em/protocols/socks4'
35
+ autoload :LineProtocol, 'em/protocols/line_protocol'
35
36
  end
36
37
  end
@@ -127,7 +127,7 @@ module EventMachine
127
127
  # Allow an override for the host header if it's not the connect-string.
128
128
  host = args[:host_header] || args[:host] || "_"
129
129
  # For now, ALWAYS tuck in the port string, although we may want to omit it if it's the default.
130
- port = args[:port]
130
+ port = args[:port].to_i != 80 ? ":#{args[:port]}" : ""
131
131
 
132
132
  # POST items.
133
133
  postcontenttype = args[:contenttype] || "application/octet-stream"
@@ -138,7 +138,7 @@ module EventMachine
138
138
  # TODO: We ASSUME the caller wants to send a 1.1 request. May not be a good assumption.
139
139
  req = [
140
140
  "#{verb} #{request}#{qs} HTTP/#{version}",
141
- "Host: #{host}:#{port}",
141
+ "Host: #{host}#{port}",
142
142
  "User-agent: Ruby EventMachine",
143
143
  ]
144
144
 
@@ -15,8 +15,8 @@ module EventMachine
15
15
  def receive_data data
16
16
  (@buf ||= '') << data
17
17
 
18
- while line = @buf.slice!(/(.*)\r?\n/)
19
- receive_line(line)
18
+ while @buf.slice!(/(.*?)\r?\n/)
19
+ receive_line($1)
20
20
  end
21
21
  end
22
22
 
@@ -506,11 +506,13 @@ module EventMachine
506
506
  # Since we clear the chunk array every time we submit it, the caller needs to be
507
507
  # aware to do things like dup it if he wants to keep it around across calls.
508
508
  #
509
- # DON'T reset the transaction upon disposition of the incoming message.
510
- # This means another DATA command can be accepted with the same sender and recipients.
511
- # If the client wants to reset, he can call RSET.
512
- # Not sure whether the standard requires a transaction-reset at this point, but it
513
- # appears not to.
509
+ # Resets the transaction upon disposition of the incoming message.
510
+ # RFC5321 says this about the MAIL FROM command:
511
+ # "This command tells the SMTP-receiver that a new mail transaction is
512
+ # starting and to reset all its state tables and buffers, including any
513
+ # recipients or mail data."
514
+ #
515
+ # Equivalent behaviour is implemented by resetting after a completed transaction.
514
516
  #
515
517
  # User-written code can return a Deferrable as a response from receive_message.
516
518
  #
@@ -524,11 +526,12 @@ module EventMachine
524
526
 
525
527
  succeeded = proc {
526
528
  send_data "250 Message accepted\r\n"
529
+ reset_protocol_state
527
530
  }
528
531
  failed = proc {
529
532
  send_data "550 Message rejected\r\n"
533
+ reset_protocol_state
530
534
  }
531
-
532
535
  d = receive_message
533
536
 
534
537
  if d.respond_to?(:set_deferred_status)
@@ -541,7 +544,7 @@ module EventMachine
541
544
  @state.delete :data
542
545
  else
543
546
  # slice off leading . if any
544
- ln.slice!(0...1) if ln[0] == 46
547
+ ln.slice!(0...1) if ln[0] == ?.
545
548
  @databuffer << ln
546
549
  if @databuffer.length > @@parms[:chunksize]
547
550
  receive_data_chunk @databuffer
@@ -104,12 +104,15 @@ module EventMachine
104
104
 
105
105
  # @private
106
106
  def send_frame verb, headers={}, body=""
107
+ body = body.to_s
107
108
  ary = [verb, "\n"]
109
+ body_bytesize = body.bytesize if body.respond_to? :bytesize
110
+ body_bytesize ||= body.size
108
111
  headers.each {|k,v| ary << "#{k}:#{v}\n" }
109
- ary << "content-length: #{body.to_s.length}\n"
112
+ ary << "content-length: #{body_bytesize}\n"
110
113
  ary << "content-type: text/plain; charset=UTF-8\n" unless headers.has_key? 'content-type'
111
114
  ary << "\n"
112
- ary << body.to_s
115
+ ary << body
113
116
  ary << "\0"
114
117
  send_data ary.join
115
118
  end
@@ -1,3 +1,3 @@
1
1
  module EventMachine
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -1156,7 +1156,12 @@ module EventMachine
1156
1156
  # Perhaps misnamed since the underlying function uses socketpair and is full-duplex.
1157
1157
 
1158
1158
  klass = klass_from_handler(Connection, handler, *args)
1159
- w = Shellwords::shellwords( cmd )
1159
+ w = case cmd
1160
+ when Array
1161
+ cmd
1162
+ when String
1163
+ Shellwords::shellwords( cmd )
1164
+ end
1160
1165
  w.unshift( w.first ) if w.first
1161
1166
  s = invoke_popen( w )
1162
1167
  c = klass.new s, *args
@@ -0,0 +1,2 @@
1
+ RUBY_VERSION =~ /(\d+.\d+)/
2
+ require "#{$1}/fastfilereaderext"
@@ -26,24 +26,29 @@ else
26
26
  unless RUBY_PLATFORM =~ /mswin|mingw/
27
27
  ext.cross_compile = true
28
28
  ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']
29
-
30
- # inject 1.8/1.9 pure-ruby entry point
31
- ext.cross_compiling do |spec|
32
- spec.files += ["lib/#{ext.name}.rb"]
33
- end
29
+ end
30
+ end
31
+ def hack_cross_compilation(ext)
32
+ # inject 1.8/1.9 pure-ruby entry point
33
+ # HACK: add these dependencies to the task instead of using cross_compiling
34
+ ext.cross_platform.each do |platform|
35
+ Rake::Task["native:#{GEMSPEC.name}:#{platform}"].prerequisites.unshift "lib/#{ext.name}.rb"
34
36
  end
35
37
  end
36
38
 
37
- Rake::ExtensionTask.new("rubyeventmachine", GEMSPEC) do |ext|
39
+ em = Rake::ExtensionTask.new("rubyeventmachine", GEMSPEC) do |ext|
38
40
  ext.ext_dir = 'ext'
39
41
  ext.source_pattern = '*.{h,c,cpp}'
40
42
  setup_cross_compilation(ext)
41
43
  end
42
- Rake::ExtensionTask.new("fastfilereaderext", GEMSPEC) do |ext|
44
+ hack_cross_compilation em
45
+
46
+ ff = Rake::ExtensionTask.new("fastfilereaderext", GEMSPEC) do |ext|
43
47
  ext.ext_dir = 'ext/fastfilereader'
44
48
  ext.source_pattern = '*.{h,c,cpp}'
45
49
  setup_cross_compilation(ext)
46
50
  end
51
+ hack_cross_compilation ff
47
52
  end
48
53
 
49
54
  # Setup shim files that require 1.8 vs 1.9 extensions in win32 bin gems
@@ -0,0 +1,33 @@
1
+ require 'em_test_helper'
2
+
3
+ class TestLineProtocol < Test::Unit::TestCase
4
+ class LineProtocolTestClass
5
+ include EM::Protocols::LineProtocol
6
+
7
+ def lines
8
+ @lines ||= []
9
+ end
10
+
11
+ def receive_line(line)
12
+ lines << line
13
+ end
14
+ end
15
+
16
+ def setup
17
+ @proto = LineProtocolTestClass.new
18
+ end
19
+
20
+ def test_simple_split_line
21
+ @proto.receive_data("this is")
22
+ assert_equal([], @proto.lines)
23
+
24
+ @proto.receive_data(" a test\n")
25
+ assert_equal(["this is a test"], @proto.lines)
26
+ end
27
+
28
+ def test_simple_lines
29
+ @proto.receive_data("aaa\nbbb\r\nccc\nddd")
30
+ assert_equal(%w(aaa bbb ccc), @proto.lines)
31
+ end
32
+
33
+ end
@@ -0,0 +1,37 @@
1
+ require 'em_test_helper'
2
+
3
+ class TestStomp < Test::Unit::TestCase
4
+ CONTENT_LENGTH_REGEX = /^content-length: (\d+)$/
5
+
6
+ def bytesize(str)
7
+ str = str.to_s
8
+ size = str.bytesize if str.respond_to?(:bytesize) # bytesize added in 1.9
9
+ size || str.size
10
+ end
11
+
12
+ def test_content_length_in_bytes
13
+ connection = Object.new
14
+ connection.instance_eval do
15
+ extend EM::P::Stomp
16
+
17
+ def last_sent_content_length
18
+ @sent && Integer(@sent[CONTENT_LENGTH_REGEX, 1])
19
+ end
20
+
21
+ def send_data(string)
22
+ @sent = string
23
+ end
24
+ end
25
+
26
+ queue = "queue"
27
+ failure_message = "header content-length is not the byte size of last sent body"
28
+
29
+ body = "test"
30
+ connection.send queue, body
31
+ assert_equal bytesize(body), connection.last_sent_content_length, failure_message
32
+
33
+ body = "test\u221A"
34
+ connection.send queue, body
35
+ assert_equal bytesize(body), connection.last_sent_content_length, failure_message
36
+ end
37
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ require 'em_test_helper'
3
+
4
+ class TestSystem < Test::Unit::TestCase
5
+ def setup
6
+ @filename = File.expand_path("../я манал dump.txt", __FILE__)
7
+ @test_data = 'a' * 100
8
+ File.open(@filename, 'w'){|f| f.write(@test_data)}
9
+ end
10
+
11
+ def test_system
12
+ result = nil
13
+ status = nil
14
+ EM.run {
15
+ EM.system('cat', @filename){|out, state|
16
+ result = out
17
+ status = state.exitstatus
18
+ EM.stop
19
+ }
20
+ }
21
+ assert_equal(0, status)
22
+ assert_equal(@test_data, result)
23
+ end
24
+
25
+ def teardown
26
+ File.unlink(@filename)
27
+ end
28
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventmachine
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: x86-mingw32
12
12
  authors:
13
13
  - Francis Cianfrocca
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-02-28 00:00:00 Z
19
+ date: 2013-03-08 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rake-compiler
@@ -232,6 +232,7 @@ files:
232
232
  - tests/test_idle_connection.rb
233
233
  - tests/test_inactivity_timeout.rb
234
234
  - tests/test_kb.rb
235
+ - tests/test_line_protocol.rb
235
236
  - tests/test_ltp.rb
236
237
  - tests/test_ltp2.rb
237
238
  - tests/test_next_tick.rb
@@ -257,16 +258,21 @@ files:
257
258
  - tests/test_ssl_args.rb
258
259
  - tests/test_ssl_methods.rb
259
260
  - tests/test_ssl_verify.rb
261
+ - tests/test_stomp.rb
262
+ - tests/test_system.rb
260
263
  - tests/test_threaded_resource.rb
261
264
  - tests/test_tick_loop.rb
262
265
  - tests/test_timers.rb
263
266
  - tests/test_ud.rb
264
267
  - tests/test_unbind_reason.rb
268
+ - lib/fastfilereaderext.rb
269
+ - lib/rubyeventmachine.rb
265
270
  - lib/1.8/rubyeventmachine.so
266
271
  - lib/1.9/rubyeventmachine.so
272
+ - lib/2.0/rubyeventmachine.so
267
273
  - lib/1.8/fastfilereaderext.so
268
274
  - lib/1.9/fastfilereaderext.so
269
- - lib/rubyeventmachine.rb
275
+ - lib/2.0/fastfilereaderext.so
270
276
  homepage: http://rubyeventmachine.com
271
277
  licenses: []
272
278