evdispatch 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.1.5 2008-04-11
2
+ * Fix a regression on linux caused from a fix to ppc
3
+
1
4
  == 0.1.4 2008-04-11
2
5
  * Fix another issue with building this time on ppc it needs ranlib executed
3
6
 
@@ -15,7 +15,10 @@ if !File.exist?("#{libdispatch}/src/.libs") or !File.exist?("#{libdispatch}/#{li
15
15
  # copy the .a files into this folder
16
16
  system("cp #{libdispatch}/src/.libs/libdispatch.a libdeps")
17
17
  system("cp #{libdispatch}/#{libev}/.libs/libev.a libdeps")
18
- system("ranlib libdeps/*.a")
18
+ if( `uname`.grep(/darwin/i) )
19
+ puts "running ranlib"
20
+ system("ranlib libdeps/*.a")
21
+ end
19
22
  end
20
23
 
21
24
  $srcs = ['revdispatch.cc']
@@ -25,7 +28,9 @@ $objs = ['revdispatch.o']
25
28
  $CPPFLAGS = " -I./#{libdispatch}/ -I./#{libdispatch}/src -I./#{libdispatch}/#{libev}/ #{$CPPFLAGS}"
26
29
 
27
30
  # link to the static library versions of libdispatch and #{libev}
28
- #$LDFLAGS << " ./#{libdispatch}/src/.libs/libdispatch.a ./#{libdispatch}/#{libev}/.libs/libev.a "
31
+ if( `uname`.grep(/linux/i) )
32
+ $LDFLAGS << " ./#{libdispatch}/src/.libs/libdispatch.a ./#{libdispatch}/#{libev}/.libs/libev.a "
33
+ end
29
34
  #$LIBS << " -L./#{libdispatch}/#{libev}/.libs/ -lev"
30
35
  #$LIBS << " -L./#{libdispatch}/src/.libs/ -ldispatch"
31
36
  $LIBS << " -Llibdeps -lev -ldispatch"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -170,8 +170,13 @@ size_t HttpRequest::write_cb(void *ptr, size_t size, size_t nmemb, void *data)
170
170
  size_t realsize = size * nmemb;
171
171
  HttpRequest *req = (HttpRequest *)data;
172
172
 
173
- req->response->body.append((const char*)ptr,realsize);
174
- //fprintf(stderr, "Write: %s (%lu) => (%d)%s\n", req->url.c_str(), realsize, (int)req->response, req->response->body.c_str() );
173
+ if( req->response ) {
174
+ req->response->body.append((const char*)ptr,realsize);
175
+ //fprintf(stderr, "Write: %s (%lu) => (%d)%s\n", req->url.c_str(), realsize, (int)req->response, req->response->body.c_str() );
176
+ }
177
+ else if( req->m_fd ) {
178
+ write( req->m_fd, ptr, realsize );
179
+ }
175
180
 
176
181
  return realsize;
177
182
  }
@@ -202,6 +207,12 @@ HttpRequest::HttpRequest( Dispatch &dispatch, const std::string &url )
202
207
  this->response->name = url;
203
208
  }
204
209
 
210
+ void HttpRequest::set_response_fd( int fd )
211
+ {
212
+ if( this->response ){ delete this->response; this->response = NULL; }
213
+ m_fd = fd;
214
+ }
215
+
205
216
  HttpRequest::~HttpRequest()
206
217
  {
207
218
  curl_easy_cleanup( m_handle );
@@ -228,10 +239,15 @@ void HttpRequest::finish(CURLcode rc)
228
239
  {
229
240
  curl_multi_remove_handle( m_client->m_handle, m_handle );
230
241
 
231
- // add the response object here to the responses queue in the dispatcher?
232
- // signaling to any waiting clients that their response is available
233
- this->response->response_time = difftime( time(NULL), this->start_time );
234
- m_client->m_disp->send_response( this->response );
242
+ if( this->response ) {
243
+ // add the response object here to the responses queue in the dispatcher?
244
+ // signaling to any waiting clients that their response is available
245
+ this->response->response_time = difftime( time(NULL), this->start_time );
246
+ m_client->m_disp->send_response( this->response );
247
+ }
248
+ else {
249
+ close( this->m_fd );
250
+ }
235
251
  //fprintf( stderr, "DONE: (%s/%s) => (%d), body(%d): '%s'\n", url.c_str(), url.c_str(), rc, (int)this->response, this->response->body.c_str() );
236
252
  }
237
253
 
@@ -50,7 +50,11 @@ namespace EVD {
50
50
 
51
51
  void finish( CURLcode rc );
52
52
 
53
- virtual void set_key( request_t key ){ Request::set_key(key); this->response->id = key; }
53
+ virtual void set_key( request_t key ){ Request::set_key(key); if( this->response ) this->response->id = key; }
54
+
55
+ // use this to have the response be written to the file instead, using a response object.
56
+ // you can not get the response to return over the normal get_next_response or wait_for_response_by_id method if you use this.
57
+ void set_response_fd( int fd );
54
58
 
55
59
  static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data);
56
60
  static int prog_cb(void *p, double dltotal, double dlnow, double ult, double uln);
@@ -60,6 +64,7 @@ namespace EVD {
60
64
  CURL *m_handle;
61
65
  HttpClient *m_client;
62
66
  char error[CURL_ERROR_SIZE];
67
+ int m_fd;
63
68
  };
64
69
 
65
70
  }
@@ -1,4 +1,4 @@
1
- bin_PROGRAMS = next_test key_test
1
+ bin_PROGRAMS = next_test key_test pipe_test
2
2
  next_test_SOURCES = next_test.cc
3
3
  next_test_CPPFLAGS = -I$(top_srcdir)/src/ -I$(LIBEV_PATH)
4
4
  next_test_LDADD = -ldispatch -lev
@@ -9,8 +9,7 @@ key_test_CPPFLAGS = -I$(top_srcdir)/src/ -I$(LIBEV_PATH)
9
9
  key_test_LDADD = -ldispatch -lev
10
10
  key_test_LDFLAGS = -L$(top_srcdir)/src/.libs/ `curl-config --libs` -L$(LIBEV_PATH)/.libs/
11
11
 
12
- test_next: next_test
13
- .libs/next_test
14
-
15
- test_key: key_test
16
- .libs/key_test
12
+ pipe_test_SOURCES = pipe_test.cc
13
+ pipe_test_CPPFLAGS = -I$(top_srcdir)/src/ -I$(LIBEV_PATH)
14
+ pipe_test_LDADD = -ldispatch -lev
15
+ pipe_test_LDFLAGS = -L$(top_srcdir)/src/.libs/ `curl-config --libs` -L$(LIBEV_PATH)/.libs/
@@ -32,7 +32,7 @@ PRE_UNINSTALL = :
32
32
  POST_UNINSTALL = :
33
33
  build_triplet = @build@
34
34
  host_triplet = @host@
35
- bin_PROGRAMS = next_test$(EXEEXT) key_test$(EXEEXT)
35
+ bin_PROGRAMS = next_test$(EXEEXT) key_test$(EXEEXT) pipe_test$(EXEEXT)
36
36
  subdir = test
37
37
  DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
38
38
  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -58,6 +58,12 @@ next_test_DEPENDENCIES =
58
58
  next_test_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
59
59
  $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
60
60
  $(CXXFLAGS) $(next_test_LDFLAGS) $(LDFLAGS) -o $@
61
+ am_pipe_test_OBJECTS = pipe_test-pipe_test.$(OBJEXT)
62
+ pipe_test_OBJECTS = $(am_pipe_test_OBJECTS)
63
+ pipe_test_DEPENDENCIES =
64
+ pipe_test_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
65
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
66
+ $(CXXFLAGS) $(pipe_test_LDFLAGS) $(LDFLAGS) -o $@
61
67
  DEFAULT_INCLUDES = -I. -I$(top_builddir)@am__isrc@
62
68
  depcomp = $(SHELL) $(top_srcdir)/depcomp
63
69
  am__depfiles_maybe = depfiles
@@ -70,8 +76,10 @@ CXXLD = $(CXX)
70
76
  CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
71
77
  --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
72
78
  $(LDFLAGS) -o $@
73
- SOURCES = $(key_test_SOURCES) $(next_test_SOURCES)
74
- DIST_SOURCES = $(key_test_SOURCES) $(next_test_SOURCES)
79
+ SOURCES = $(key_test_SOURCES) $(next_test_SOURCES) \
80
+ $(pipe_test_SOURCES)
81
+ DIST_SOURCES = $(key_test_SOURCES) $(next_test_SOURCES) \
82
+ $(pipe_test_SOURCES)
75
83
  ETAGS = etags
76
84
  CTAGS = ctags
77
85
  DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -191,6 +199,10 @@ key_test_SOURCES = key_test.cc
191
199
  key_test_CPPFLAGS = -I$(top_srcdir)/src/ -I$(LIBEV_PATH)
192
200
  key_test_LDADD = -ldispatch -lev
193
201
  key_test_LDFLAGS = -L$(top_srcdir)/src/.libs/ `curl-config --libs` -L$(LIBEV_PATH)/.libs/
202
+ pipe_test_SOURCES = pipe_test.cc
203
+ pipe_test_CPPFLAGS = -I$(top_srcdir)/src/ -I$(LIBEV_PATH)
204
+ pipe_test_LDADD = -ldispatch -lev
205
+ pipe_test_LDFLAGS = -L$(top_srcdir)/src/.libs/ `curl-config --libs` -L$(LIBEV_PATH)/.libs/
194
206
  all: all-am
195
207
 
196
208
  .SUFFIXES:
@@ -258,6 +270,9 @@ key_test$(EXEEXT): $(key_test_OBJECTS) $(key_test_DEPENDENCIES)
258
270
  next_test$(EXEEXT): $(next_test_OBJECTS) $(next_test_DEPENDENCIES)
259
271
  @rm -f next_test$(EXEEXT)
260
272
  $(next_test_LINK) $(next_test_OBJECTS) $(next_test_LDADD) $(LIBS)
273
+ pipe_test$(EXEEXT): $(pipe_test_OBJECTS) $(pipe_test_DEPENDENCIES)
274
+ @rm -f pipe_test$(EXEEXT)
275
+ $(pipe_test_LINK) $(pipe_test_OBJECTS) $(pipe_test_LDADD) $(LIBS)
261
276
 
262
277
  mostlyclean-compile:
263
278
  -rm -f *.$(OBJEXT)
@@ -267,6 +282,7 @@ distclean-compile:
267
282
 
268
283
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/key_test-key_test.Po@am__quote@
269
284
  @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/next_test-next_test.Po@am__quote@
285
+ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pipe_test-pipe_test.Po@am__quote@
270
286
 
271
287
  .cc.o:
272
288
  @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -317,6 +333,20 @@ next_test-next_test.obj: next_test.cc
317
333
  @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
318
334
  @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(next_test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o next_test-next_test.obj `if test -f 'next_test.cc'; then $(CYGPATH_W) 'next_test.cc'; else $(CYGPATH_W) '$(srcdir)/next_test.cc'; fi`
319
335
 
336
+ pipe_test-pipe_test.o: pipe_test.cc
337
+ @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pipe_test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT pipe_test-pipe_test.o -MD -MP -MF $(DEPDIR)/pipe_test-pipe_test.Tpo -c -o pipe_test-pipe_test.o `test -f 'pipe_test.cc' || echo '$(srcdir)/'`pipe_test.cc
338
+ @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/pipe_test-pipe_test.Tpo $(DEPDIR)/pipe_test-pipe_test.Po
339
+ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='pipe_test.cc' object='pipe_test-pipe_test.o' libtool=no @AMDEPBACKSLASH@
340
+ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
341
+ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pipe_test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pipe_test-pipe_test.o `test -f 'pipe_test.cc' || echo '$(srcdir)/'`pipe_test.cc
342
+
343
+ pipe_test-pipe_test.obj: pipe_test.cc
344
+ @am__fastdepCXX_TRUE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pipe_test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT pipe_test-pipe_test.obj -MD -MP -MF $(DEPDIR)/pipe_test-pipe_test.Tpo -c -o pipe_test-pipe_test.obj `if test -f 'pipe_test.cc'; then $(CYGPATH_W) 'pipe_test.cc'; else $(CYGPATH_W) '$(srcdir)/pipe_test.cc'; fi`
345
+ @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/pipe_test-pipe_test.Tpo $(DEPDIR)/pipe_test-pipe_test.Po
346
+ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='pipe_test.cc' object='pipe_test-pipe_test.obj' libtool=no @AMDEPBACKSLASH@
347
+ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
348
+ @am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(pipe_test_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o pipe_test-pipe_test.obj `if test -f 'pipe_test.cc'; then $(CYGPATH_W) 'pipe_test.cc'; else $(CYGPATH_W) '$(srcdir)/pipe_test.cc'; fi`
349
+
320
350
  mostlyclean-libtool:
321
351
  -rm -f *.lo
322
352
 
@@ -502,12 +532,6 @@ uninstall-am: uninstall-binPROGRAMS
502
532
  pdf pdf-am ps ps-am tags uninstall uninstall-am \
503
533
  uninstall-binPROGRAMS
504
534
 
505
-
506
- test_next: next_test
507
- .libs/next_test
508
-
509
- test_key: key_test
510
- .libs/key_test
511
535
  # Tell versions [3.59,3.63) of GNU make to not export all variables.
512
536
  # Otherwise a system limit (for SysV at least) may be exceeded.
513
537
  .NOEXPORT:
@@ -29,10 +29,9 @@ static void run_tests( Dispatch &dispatcher, int count )
29
29
  //ev_sleep(0.2);
30
30
 
31
31
  Response *rep = NULL;
32
- Timer timeout(2,0);
33
32
  double longest_request = 0.0;
34
33
 
35
- while( expected_response_count > 0 && (rep = dispatcher.get_next_response(timeout)) ){
34
+ while( expected_response_count > 0 && (rep = dispatcher.get_next_response(Timer(1,0))) ){
36
35
  if( longest_request < rep->response_time ){
37
36
  longest_request = rep->response_time;
38
37
  }
@@ -58,3 +58,6 @@ def start_test_server
58
58
  # keep process alive
59
59
  sleep 0.5 while Ebb.running?
60
60
  end
61
+ if( ARGV[0] == "start" )
62
+ start_test_server
63
+ end
@@ -3,7 +3,8 @@ require 'revdispatch'
3
3
  # to run this through valgrind run the server outside of this script
4
4
  # i run this: valgrind --leak-check=full ~/project/ruby-valgrind-env/bin/ruby test.rb r
5
5
  pid = nil
6
- unless ARGV[0] == 'r'
6
+ running_ebb_here = (ARGV[0] != 'r' and !`uname`.grep(/darwin/i))
7
+ if running_ebb_here
7
8
  pid = fork do
8
9
  require 'server'
9
10
  start_test_server
@@ -78,7 +79,7 @@ def run_trial
78
79
  end
79
80
 
80
81
  begin
81
- sleep 1 unless ARGV[0] == 'r'
82
+ sleep 1 if running_ebb_here
82
83
 
83
84
  ObjectSpace.garbage_collect
84
85
 
@@ -92,7 +93,6 @@ begin
92
93
  end
93
94
 
94
95
 
95
- Process.kill('HUP', pid) unless ARGV[0] == 'r'
96
96
  count = ObjectSpace.each_object { }
97
97
  puts "Final Total objects: #{count}"
98
98
  count = nil
@@ -101,3 +101,4 @@ end
101
101
 
102
102
  count = ObjectSpace.each_object { }
103
103
  puts "After garbage collection objects: #{count}"
104
+ Process.kill('HUP', pid) if running_ebb_here
@@ -2,7 +2,7 @@ module Evdispatch #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- TINY = 4
5
+ TINY = 5
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/script/console CHANGED
File without changes
data/script/destroy CHANGED
File without changes
data/script/generate CHANGED
File without changes
data/script/txt2html CHANGED
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evdispatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd A. Fisher
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-11 00:00:00 -04:00
12
+ date: 2008-04-12 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -146,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
146
  requirements: []
147
147
 
148
148
  rubyforge_project: evdispatch
149
- rubygems_version: 1.0.1
149
+ rubygems_version: 1.1.0
150
150
  signing_key:
151
151
  specification_version: 2
152
152
  summary: Based on libev provides a background event loop for making simulataneous requests