@@ -87,7 +87,7 @@ Persistent<FunctionTemplate> ILob::iLobTemplate_s;
87
87
*/
88
88
89
89
ILob::ILob ():
90
- lobLocator_(NULL ), dpiconn_(NULL ), svch_(NULL ), errh_(NULL ),
90
+ lobLocator_(NULL ), njsconn_( NULL ), dpiconn_(NULL ), svch_(NULL ), errh_(NULL ),
91
91
isValid_(false ), state_(INACTIVE), buf_(NULL ), bufSize_(0 ), chunkSize_(0 ),
92
92
length_(0 ), offset_(1 ), amountRead_(0 )
93
93
{
@@ -200,30 +200,41 @@ void ILob::setILob(eBaton *executeBaton, ProtoILob *protoILob)
200
200
// exceptions.
201
201
try
202
202
{
203
- lobLocator_ = protoILob->lobLocator_ ;
203
+ // Lob details
204
+ lobLocator_ = protoILob->lobLocator_ ;
204
205
protoILob->lobLocator_ = NULL ;
205
-
206
- fetchType_ = protoILob->fetchType_ ;
206
+ fetchType_ = protoILob->fetchType_ ;
207
207
208
- dpiconn_ = executeBaton->dpiconn ;
209
- svch_ = executeBaton->dpiconn ->getSvch ();
210
-
211
- errh_ = protoILob->errh_ ;
212
- protoILob->errh_ = NULL ;
213
-
214
- length_ = protoILob->length_ ;
215
-
216
- chunkSize_ = protoILob->chunkSize_ ;
217
- bufSize_ = chunkSize_;
218
- // we can move the allocation of buf_ to the
219
- // worker thread also by alloating the buf_ in
220
- // ProtoILob.
208
+ // connection
209
+ njsconn_ = executeBaton->njsconn ;
210
+ dpiconn_ = executeBaton->dpiconn ;
211
+ svch_ = executeBaton->dpiconn ->getSvch ();
212
+
213
+ // error
214
+ errh_ = protoILob->errh_ ;
215
+ protoILob->errh_ = NULL ;
216
+
217
+ // LOB meta data
218
+ length_ = protoILob->length_ ;
219
+ chunkSize_ = protoILob->chunkSize_ ;
220
+ bufSize_ = chunkSize_;
221
+
222
+ /*
223
+ * we can move the allocation of buf_ to the worker thread also by
224
+ * allocating the buf_ in ProtoILob.
225
+ */
221
226
if (fetchType_ == DpiClob)
222
- buf_ = new char [bufSize_ * 4 ]; // accommodate multi-byte charsets
227
+ {
228
+ // accommodate multi-byte charsets
229
+ buf_ = new char [bufSize_ * dpiconn_->getByteExpansionRatio ()];
230
+ }
223
231
else
232
+ {
224
233
buf_ = new char [bufSize_];
234
+ }
225
235
226
- isValid_ = true ;
236
+ // Now the ILob object is valid
237
+ isValid_ = true ;
227
238
}
228
239
229
240
catch (dpi::Exception &e)
@@ -337,6 +348,14 @@ NAN_METHOD(ILob::Release)
337
348
NanScope ();
338
349
339
350
ILob *iLob = ObjectWrap::Unwrap<ILob>(args.This ());
351
+ string msg;
352
+
353
+ if ( !iLob->njsconn_ ->isValid () )
354
+ {
355
+ msg = NJSMessages::getErrorMsg ( errInvalidConnection );
356
+ NJS_SET_EXCEPTION ( msg.c_str (), (int ) msg.length () );
357
+ NanReturnUndefined ();
358
+ }
340
359
341
360
iLob->cleanup ();
342
361
@@ -368,7 +387,7 @@ void ILob::lobPropertyException(ILob *iLob,
368
387
string property)
369
388
{
370
389
NanScope ();
371
- string msg;
390
+ string msg;
372
391
373
392
if (iLob->isValid_ )
374
393
msg = NJSMessages::getErrorMsg (err, property.c_str ());
@@ -400,6 +419,14 @@ NAN_PROPERTY_GETTER(ILob::GetChunkSize)
400
419
NanScope ();
401
420
402
421
ILob *iLob = ObjectWrap::Unwrap<ILob>(args.Holder ());
422
+ string msg;
423
+
424
+ if ( !iLob->njsconn_ ->isValid () )
425
+ {
426
+ msg = NJSMessages::getErrorMsg ( errInvalidConnection );
427
+ NJS_SET_EXCEPTION ( msg.c_str (), (int ) msg.length () );
428
+ NanReturnUndefined ();
429
+ }
403
430
404
431
try
405
432
{
@@ -464,6 +491,14 @@ NAN_PROPERTY_GETTER(ILob::GetLength)
464
491
NanScope ();
465
492
466
493
ILob *iLob = ObjectWrap::Unwrap<ILob>(args.Holder ());
494
+ string msg;
495
+
496
+ if ( !iLob->njsconn_ ->isValid () )
497
+ {
498
+ msg = NJSMessages::getErrorMsg ( errInvalidConnection );
499
+ NJS_SET_EXCEPTION ( msg.c_str (), (int ) msg.length () );
500
+ NanReturnUndefined ();
501
+ }
467
502
468
503
try
469
504
{
@@ -527,6 +562,14 @@ NAN_PROPERTY_GETTER(ILob::GetPieceSize)
527
562
NanScope ();
528
563
529
564
ILob *iLob = ObjectWrap::Unwrap<ILob>(args.Holder ());
565
+ string msg;
566
+
567
+ if ( !iLob->njsconn_ ->isValid () )
568
+ {
569
+ msg = NJSMessages::getErrorMsg ( errInvalidConnection );
570
+ NJS_SET_EXCEPTION ( msg.c_str (), (int ) msg.length () );
571
+ NanReturnUndefined ();
572
+ }
530
573
531
574
try
532
575
{
@@ -565,21 +608,34 @@ NAN_SETTER(ILob::SetPieceSize)
565
608
NanScope ();
566
609
567
610
ILob *iLob = ObjectWrap::Unwrap<ILob>(args.Holder ());
611
+ string msg;
568
612
569
613
NJS_SET_PROP_UINT (iLob->bufSize_ , value, " pieceSize" );
570
614
571
615
if (iLob->state_ == ACTIVE)
572
616
{
573
- string msg = NJSMessages::getErrorMsg (errBusyLob);
617
+ msg = NJSMessages::getErrorMsg (errBusyLob);
574
618
575
619
NJS_SET_EXCEPTION (msg.c_str (), (int )msg.length ());
620
+ return ;
621
+ }
622
+
623
+ if ( !iLob->njsconn_ ->isValid () )
624
+ {
625
+ msg = NJSMessages::getErrorMsg ( errInvalidConnection );
626
+ NJS_SET_EXCEPTION ( msg.c_str (), (int ) msg.length () );
627
+ return ;
576
628
}
577
629
578
630
if (iLob->buf_ )
579
631
delete [] iLob->buf_ ;
580
632
581
633
if (iLob->fetchType_ == DpiClob)
582
- iLob->buf_ = new char [iLob->bufSize_ * 4 ];// accommodate multi-byte charsets
634
+ {
635
+ // accommodate multi-byte charsets
636
+ iLob->buf_ = new char [iLob->bufSize_ *
637
+ iLob->dpiconn_ ->getByteExpansionRatio ()];
638
+ }
583
639
else
584
640
iLob->buf_ = new char [iLob->bufSize_ ];
585
641
}
@@ -606,6 +662,14 @@ NAN_PROPERTY_GETTER(ILob::GetOffset)
606
662
NanScope ();
607
663
608
664
ILob *iLob = ObjectWrap::Unwrap<ILob>(args.Holder ());
665
+ string msg;
666
+
667
+ if ( !iLob->njsconn_ ->isValid () )
668
+ {
669
+ msg = NJSMessages::getErrorMsg ( errInvalidConnection );
670
+ NJS_SET_EXCEPTION ( msg.c_str (), (int ) msg.length () );
671
+ NanReturnUndefined ();
672
+ }
609
673
610
674
try
611
675
{
@@ -645,6 +709,7 @@ NAN_SETTER(ILob::SetOffset)
645
709
646
710
ILob *iLob = ObjectWrap::Unwrap<ILob>(args.Holder ());
647
711
double offset = 0.0 ;
712
+ string msg;
648
713
649
714
NJS_SET_PROP_UINT (offset, value, " offset" );
650
715
@@ -657,9 +722,17 @@ NAN_SETTER(ILob::SetOffset)
657
722
658
723
if (iLob->state_ == ACTIVE)
659
724
{
660
- string msg = NJSMessages::getErrorMsg (errBusyLob);
725
+ msg = NJSMessages::getErrorMsg (errBusyLob);
661
726
662
727
NJS_SET_EXCEPTION (msg.c_str (), (int )msg.length ());
728
+ return ;
729
+ }
730
+
731
+ if ( !iLob->njsconn_ ->isValid () )
732
+ {
733
+ msg = NJSMessages::getErrorMsg ( errInvalidConnection );
734
+ NJS_SET_EXCEPTION ( msg.c_str (), (int ) msg.length () );
735
+ return ;
663
736
}
664
737
665
738
iLob->offset_ = (unsigned long long ) offset;
@@ -709,6 +782,12 @@ NAN_METHOD(ILob::Read)
709
782
// case of an error.
710
783
iLob->state_ = ACTIVE;
711
784
785
+ if ( !iLob->njsconn_ ->isValid () )
786
+ {
787
+ lobBaton->error = NJSMessages::getErrorMsg ( errInvalidConnection );
788
+ goto exitRead;
789
+ }
790
+
712
791
exitRead:
713
792
714
793
lobBaton->req .data = (void *)lobBaton;
@@ -894,6 +973,12 @@ NAN_METHOD(ILob::Write)
894
973
// case of an error
895
974
iLob->state_ = ACTIVE;
896
975
976
+ if ( !iLob->njsconn_ ->isValid () )
977
+ {
978
+ lobBaton->error = NJSMessages::getErrorMsg ( errInvalidConnection );
979
+ goto exitWrite;
980
+ }
981
+
897
982
exitWrite:
898
983
899
984
lobBaton->req .data = (void *)lobBaton;
0 commit comments