ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro-Mysql/Mysql.xs
(Generate patch)

Comparing Coro-Mysql/Mysql.xs (file contents):
Revision 1.8 by root, Thu Jul 26 21:38:00 2012 UTC vs.
Revision 1.10 by root, Fri Aug 2 04:08:56 2013 UTC

21static CV *readable, *writable; 21static CV *readable, *writable;
22static int use_ev; 22static int use_ev;
23 23
24#include "violite.h" 24#include "violite.h"
25 25
26#define DESC_OFFSET 22
27
28#define CoMy_MAGIC 0x436f4d79 26#define CoMy_MAGIC 0x436f4d79
29 27
30typedef struct { 28typedef struct {
29#if DESC_IS_PTR
30 char desc[30];
31 const char *old_desc;
32#endif
31 int magic; 33 int magic;
32 SV *corohandle_sv, *corohandle; 34 SV *corohandle_sv, *corohandle;
33 int bufofs, bufcnt; 35 int bufofs, bufcnt;
34#if HAVE_EV 36#if HAVE_EV
35 ev_io rw, ww; 37 ev_io rw, ww;
36#endif 38#endif
37 char buf[VIO_READ_BUFFER_SIZE]; 39 char buf[VIO_READ_BUFFER_SIZE];
38} ourdata; 40} ourdata;
39 41
42#if DESC_IS_PTR
43# define OURDATAPTR (*(ourdata **)&((vio)->desc))
44#else
45# define DESC_OFFSET 22
40#define OURDATAPTR (*((ourdata **)((vio)->desc + DESC_OFFSET))) 46# define OURDATAPTR (*((ourdata **)((vio)->desc + DESC_OFFSET)))
47#endif
41 48
42static xlen 49static xlen
43our_read (Vio *vio, xgptr p, xlen len) 50our_read (Vio *vio, xgptr p, xlen len)
44{ 51{
45 ourdata *our = OURDATAPTR; 52 ourdata *our = OURDATAPTR;
165#endif 172#endif
166 173
167 SvREFCNT_dec (our->corohandle); 174 SvREFCNT_dec (our->corohandle);
168 SvREFCNT_dec (our->corohandle_sv); 175 SvREFCNT_dec (our->corohandle_sv);
169 176
177#if DESC_IS_PTR
178 vio->desc = our->old_desc;
179#endif
180
170 Safefree (our); 181 Safefree (our);
171 182
172 vio->read = vio_read; 183 vio->read = vio_read;
173 vio->write = vio_write; 184 vio->write = vio_write;
174 vio->vioclose = vio_close; 185 vio->vioclose = vio_close;
232 243
233 if (fd != vio->sd) 244 if (fd != vio->sd)
234 croak ("DBD::mysql fd and vio-sd disagree - library mismatch, unsupported transport or API changes?"); 245 croak ("DBD::mysql fd and vio-sd disagree - library mismatch, unsupported transport or API changes?");
235 246
236 if (vio->vioclose != vio_close) 247 if (vio->vioclose != vio_close)
237 croak ("vio.write has unexpected content - library mismatch, unsupported transport or API changes?"); 248 croak ("vio.vioclose has unexpected content - library mismatch, unsupported transport or API changes?");
238 249
239 if (vio->write != vio_write) 250 if (vio->write != vio_write)
240 croak ("vio.write has unexpected content - library mismatch, unsupported transport or API changes?"); 251 croak ("vio.write has unexpected content - library mismatch, unsupported transport or API changes?");
241 252
242 if (vio->read != vio_read 253 if (vio->read != vio_read
252 { 263 {
253 ev_io_init (&(our->rw), iocb, vio->sd, EV_READ); 264 ev_io_init (&(our->rw), iocb, vio->sd, EV_READ);
254 ev_io_init (&(our->ww), iocb, vio->sd, EV_WRITE); 265 ev_io_init (&(our->ww), iocb, vio->sd, EV_WRITE);
255 } 266 }
256#endif 267#endif
257 268#if DESC_IS_PTR
269 our->old_desc = vio->desc;
270 strncpy (our->desc, vio->desc, sizeof (our->desc));
271 our->desc [sizeof (our->desc) - 1] = 0;
272#else
258 vio->desc [DESC_OFFSET - 1] = 0; 273 vio->desc [DESC_OFFSET - 1] = 0;
274#endif
259 OURDATAPTR = our; 275 OURDATAPTR = our;
260 276
261 vio->vioclose = our_close; 277 vio->vioclose = our_close;
262 vio->write = our_write; 278 vio->write = our_write;
263 vio->read = our_read; 279 vio->read = our_read;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines