forked from php-amqp/php-amqp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amqp_connection.c
1798 lines (1392 loc) · 62.9 KB
/
amqp_connection.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2007 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
| Lead: |
| - Pieter de Zwart |
| Maintainers: |
| - Brad Rodriguez |
| - Jonathan Tansavatdi |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "zend_exceptions.h"
#ifdef PHP_WIN32
# if PHP_VERSION_ID >= 80000
# include "main/php_stdint.h"
# else
# include "win32/php_stdint.h"
# endif
# include "win32/signal.h"
#else
# include <signal.h>
# include <stdint.h>
#endif
#include <amqp.h>
#include <amqp_framing.h>
#include <amqp_tcp_socket.h>
#ifdef PHP_WIN32
# include "win32/unistd.h"
#else
# include <unistd.h>
#endif
#include "php_amqp.h"
#include "amqp_channel.h"
#include "amqp_connection_resource.h"
#include "amqp_connection.h"
#ifndef E_DEPRECATED
#define E_DEPRECATED E_WARNING
#endif
zend_class_entry *amqp_connection_class_entry;
#define this_ce amqp_connection_class_entry
zend_object_handlers amqp_connection_object_handlers;
#define PHP_AMQP_EXTRACT_CONNECTION_STR(name) \
zdata = NULL; \
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), (name), sizeof(name), zdata)) { \
SEPARATE_ZVAL(zdata); \
convert_to_string(PHP5to7_MAYBE_DEREF(zdata)); \
} \
if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) { \
zend_update_property_string(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL(name), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); \
} else { \
zend_update_property_string(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL(name), INI_STR("amqp." name) TSRMLS_CC); \
}
#define PHP_AMQP_EXTRACT_CONNECTION_BOOL(name) \
zdata = NULL; \
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), (name), sizeof(name), zdata)) { \
SEPARATE_ZVAL(zdata); \
convert_to_long(PHP5to7_MAYBE_DEREF(zdata)); \
} \
if (zdata) { \
zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL(name), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); \
} else { \
zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL(name), INI_INT("amqp." name) TSRMLS_CC); \
}
static int php_amqp_connection_resource_deleter(PHP5to7_zend_resource_le_t *el, amqp_connection_resource *connection_resource TSRMLS_DC)
{
if (Z_RES_P(el)->ptr == connection_resource) {
return ZEND_HASH_APPLY_REMOVE | ZEND_HASH_APPLY_STOP;
}
return ZEND_HASH_APPLY_KEEP;
}
static PHP5to7_param_str_len_type_t php_amqp_get_connection_hash(amqp_connection_params *params, char **hash) {
return spprintf(hash,
0,
"amqp_conn_res_h:%s_p:%d_v:%s_l:%s_p:%s_f:%d_c:%d_h:%d_cacert:%s_capath:%s_cert:%s_key:%s_sasl_method:%d_connection_name:%s",
params->host,
params->port,
params->vhost,
params->login,
params->password,
params->frame_max,
params->channel_max,
params->heartbeat,
params->cacert,
params->capath,
params->cert,
params->key,
params->sasl_method,
params->connection_name
);
}
static void php_amqp_cleanup_connection_resource(amqp_connection_resource *connection_resource TSRMLS_DC)
{
if (!connection_resource) {
return;
}
PHP5to7_zend_resource_t resource = connection_resource->resource;
connection_resource->parent->connection_resource = NULL;
connection_resource->parent = NULL;
if (connection_resource->is_dirty) {
if (connection_resource->is_persistent) {
zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t)php_amqp_connection_resource_deleter, (void*)connection_resource TSRMLS_CC);
}
zend_list_delete(resource);
} else {
if (connection_resource->is_persistent) {
connection_resource->resource = PHP5to7_ZEND_RESOURCE_EMPTY;
}
if (connection_resource->resource != PHP5to7_ZEND_RESOURCE_EMPTY) {
zend_list_delete(resource);
}
}
}
static void php_amqp_disconnect(amqp_connection_resource *resource TSRMLS_DC)
{
php_amqp_prepare_for_disconnect(resource TSRMLS_CC);
php_amqp_cleanup_connection_resource(resource TSRMLS_CC);
}
void php_amqp_disconnect_force(amqp_connection_resource *resource TSRMLS_DC)
{
php_amqp_prepare_for_disconnect(resource TSRMLS_CC);
resource->is_dirty = '\1';
php_amqp_cleanup_connection_resource(resource TSRMLS_CC);
}
/**
* php_amqp_connect
* handles connecting to amqp
* called by connect(), pconnect(), reconnect(), preconnect()
*/
int php_amqp_connect(amqp_connection_object *connection, zend_bool persistent, INTERNAL_FUNCTION_PARAMETERS)
{
PHP5to7_READ_PROP_RV_PARAM_DECL;
char *key = NULL;
PHP5to7_param_str_len_type_t key_len = 0;
if (connection->connection_resource) {
/* Clean up old memory allocations which are now invalid (new connection) */
php_amqp_cleanup_connection_resource(connection->connection_resource TSRMLS_CC);
}
assert(connection->connection_resource == NULL);
amqp_connection_params connection_params;
connection_params.host = PHP_AMQP_READ_THIS_PROP_STR("host");
connection_params.port = (int)PHP_AMQP_READ_THIS_PROP_LONG("port");
connection_params.vhost = PHP_AMQP_READ_THIS_PROP_STR("vhost");
connection_params.login = PHP_AMQP_READ_THIS_PROP_STR("login");
connection_params.password = PHP_AMQP_READ_THIS_PROP_STR("password");
connection_params.frame_max = (int) PHP_AMQP_READ_THIS_PROP_LONG("frame_max");
connection_params.channel_max = (int) PHP_AMQP_READ_THIS_PROP_LONG("channel_max");
connection_params.heartbeat = (int) PHP_AMQP_READ_THIS_PROP_LONG("heartbeat");
connection_params.read_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("read_timeout");
connection_params.write_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("write_timeout");
connection_params.connect_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("connect_timeout");
connection_params.rpc_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("rpc_timeout");
connection_params.cacert = PHP_AMQP_READ_THIS_PROP_STRLEN("cacert") ? PHP_AMQP_READ_THIS_PROP_STR("cacert") : NULL;
connection_params.capath = PHP_AMQP_READ_THIS_PROP_STRLEN("capath") ? PHP_AMQP_READ_THIS_PROP_STR("capath") : NULL;
connection_params.use_default_cacert = (int) PHP_AMQP_READ_THIS_PROP_BOOL("use_default_cacert");
connection_params.use_default_capath = (int) PHP_AMQP_READ_THIS_PROP_BOOL("use_default_capath");
connection_params.cert = PHP_AMQP_READ_THIS_PROP_STRLEN("cert") ? PHP_AMQP_READ_THIS_PROP_STR("cert") : NULL;
connection_params.key = PHP_AMQP_READ_THIS_PROP_STRLEN("key") ? PHP_AMQP_READ_THIS_PROP_STR("key") : NULL;
connection_params.verify = (int) PHP_AMQP_READ_THIS_PROP_BOOL("verify");
connection_params.sasl_method = (int) PHP_AMQP_READ_THIS_PROP_LONG("sasl_method");
connection_params.connection_name = PHP_AMQP_READ_THIS_PROP_STRLEN("connection_name") ? PHP_AMQP_READ_THIS_PROP_STR("connection_name") : NULL;
if (persistent) {
PHP5to7_zend_resource_store_t *le = PHP5to7_ZEND_RESOURCE_EMPTY;
/* Look for an established resource */
key_len = php_amqp_get_connection_hash(&connection_params, &key);
if (PHP5to7_ZEND_HASH_STR_FIND_PTR(&EG(persistent_list), key, key_len, le)) {
efree(key);
if (le->type != le_amqp_connection_resource_persistent) {
/* hash conflict, given name associate with non-amqp persistent connection resource */
return 0;
}
/* An entry for this connection resource already exists */
/* Stash the connection resource in the connection */
connection->connection_resource = le->ptr;
if (connection->connection_resource->resource != PHP5to7_ZEND_RESOURCE_EMPTY) {
/* resource in use! */
connection->connection_resource = NULL;
zend_throw_exception(amqp_connection_exception_class_entry, "There are already established persistent connection to the same resource.", 0 TSRMLS_CC);
return 0;
}
connection->connection_resource->resource = PHP5to7_ZEND_REGISTER_RESOURCE(connection->connection_resource, persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource);
connection->connection_resource->parent = connection;
/* Set desired timeouts */
if (php_amqp_set_resource_read_timeout(connection->connection_resource, PHP_AMQP_READ_THIS_PROP_DOUBLE("read_timeout") TSRMLS_CC) == 0
|| php_amqp_set_resource_write_timeout(connection->connection_resource, PHP_AMQP_READ_THIS_PROP_DOUBLE("write_timeout") TSRMLS_CC) == 0
|| php_amqp_set_resource_rpc_timeout(connection->connection_resource, PHP_AMQP_READ_THIS_PROP_DOUBLE("rpc_timeout") TSRMLS_CC) == 0) {
php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC);
return 0;
}
/* Set connection status to connected */
connection->connection_resource->is_connected = '\1';
connection->connection_resource->is_persistent = persistent;
return 1;
}
efree(key);
}
connection->connection_resource = connection_resource_constructor(&connection_params, persistent TSRMLS_CC);
if (connection->connection_resource == NULL) {
return 0;
}
connection->connection_resource->resource = PHP5to7_ZEND_REGISTER_RESOURCE(connection->connection_resource, persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource);
connection->connection_resource->parent = connection;
/* Set connection status to connected */
connection->connection_resource->is_connected = '\1';
if (persistent) {
connection->connection_resource->is_persistent = persistent;
key_len = php_amqp_get_connection_hash(&connection_params, &key);
PHP5to7_zend_resource_store_t new_le;
/* Store a reference in the persistence list */
new_le.ptr = connection->connection_resource;
new_le.type = persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource;
if (!PHP5to7_ZEND_HASH_STR_UPD_MEM(&EG(persistent_list), key, key_len, new_le, sizeof(PHP5to7_zend_resource_store_t))) {
efree(key);
php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC);
return 0;
}
efree(key);
}
return 1;
}
void amqp_connection_free(PHP5to7_obj_free_zend_object *object TSRMLS_DC)
{
amqp_connection_object *connection = PHP_AMQP_FETCH_CONNECTION(object);
if (connection->connection_resource) {
php_amqp_disconnect(connection->connection_resource TSRMLS_CC);
}
zend_object_std_dtor(&connection->zo TSRMLS_CC);
#if PHP_MAJOR_VERSION < 7
efree(object);
#endif
}
PHP5to7_zend_object_value amqp_connection_ctor(zend_class_entry *ce TSRMLS_DC)
{
amqp_connection_object* connection = PHP5to7_ECALLOC_CONNECTION_OBJECT(ce);
zend_object_std_init(&connection->zo, ce TSRMLS_CC);
AMQP_OBJECT_PROPERTIES_INIT(connection->zo, ce);
#if PHP_MAJOR_VERSION >=7
connection->zo.handlers = &amqp_connection_object_handlers;
return &connection->zo;
#else
PHP5to7_zend_object_value new_value;
new_value.handle = zend_objects_store_put(
connection,
NULL,
(zend_objects_free_object_storage_t) amqp_connection_free,
NULL TSRMLS_CC
);
new_value.handlers = zend_get_std_object_handlers();
return new_value;
#endif
}
/* {{{ proto AMQPConnection::__construct([array optional])
* The array can contain 'host', 'port', 'login', 'password', 'vhost', 'read_timeout', 'write_timeout', 'connect_timeout', 'rpc_timeout' and 'timeout' (deprecated) indexes
*/
static PHP_METHOD(amqp_connection_class, __construct)
{
zval* ini_arr = NULL;
PHP5to7_zval_t *zdata = NULL;
/* Parse out the method parameters */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a/", &ini_arr) == FAILURE) {
return;
}
/* Pull the login out of the $params array */
zdata = NULL;
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "login", sizeof("login"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_string(PHP5to7_MAYBE_DEREF(zdata));
}
/* Validate the given login */
if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) {
if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) {
zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("login"), PHP5to7_MAYBE_DEREF(zdata)TSRMLS_CC);
} else {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'login' exceeds 128 character limit.", 0 TSRMLS_CC);
return;
}
} else {
zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("login"), INI_STR("amqp.login"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.login")) > 128 ? 128 : strlen(INI_STR("amqp.login"))) TSRMLS_CC);
}
/* Pull the password out of the $params array */
zdata = NULL;
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "password", sizeof("password"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_string(PHP5to7_MAYBE_DEREF(zdata));
}
/* Validate the given password */
if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) {
if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) {
zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("password"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)), Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
} else {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'password' exceeds 128 character limit.", 0 TSRMLS_CC);
return;
}
} else {
zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("password"), INI_STR("amqp.password"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.password")) > 128 ? 128 : strlen(INI_STR("amqp.password"))) TSRMLS_CC);
}
/* Pull the host out of the $params array */
zdata = NULL;
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "host", sizeof("host"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_string(PHP5to7_MAYBE_DEREF(zdata));
}
/* Validate the given host */
if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) {
if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) {
zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("host"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)), Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
} else {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'host' exceeds 128 character limit.", 0 TSRMLS_CC);
return;
}
} else {
zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("host"), INI_STR("amqp.host"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.host")) > 128 ? 128 : strlen(INI_STR("amqp.host"))) TSRMLS_CC);
}
/* Pull the vhost out of the $params array */
zdata = NULL;
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "vhost", sizeof("vhost"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_string(PHP5to7_MAYBE_DEREF(zdata));
}
/* Validate the given vhost */
if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) {
if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) {
zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("vhost"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)), Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
} else {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'vhost' exceeds 128 character limit.", 0 TSRMLS_CC);
return;
}
} else {
zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("vhost"), INI_STR("amqp.vhost"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.vhost")) > 128 ? 128 : strlen(INI_STR("amqp.vhost"))) TSRMLS_CC);
}
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("port"), INI_INT("amqp.port") TSRMLS_CC);
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "port", sizeof("port"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_long(PHP5to7_MAYBE_DEREF(zdata));
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("port"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
}
zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), INI_FLT("amqp.read_timeout") TSRMLS_CC);
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "read_timeout", sizeof("read_timeout"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_double(PHP5to7_MAYBE_DEREF(zdata));
if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'read_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
} else {
zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
}
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "timeout", sizeof("timeout"), zdata)) {
/* 'read_timeout' takes precedence on 'timeout' but users have to know this */
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter 'timeout' is deprecated, 'read_timeout' used instead");
}
} else if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "timeout", sizeof("timeout"), zdata)) {
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "Parameter 'timeout' is deprecated; use 'read_timeout' instead");
SEPARATE_ZVAL(zdata);
convert_to_double(PHP5to7_MAYBE_DEREF(zdata));
if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
} else {
zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
}
} else {
assert(DEFAULT_TIMEOUT != NULL);
if (strcmp(DEFAULT_TIMEOUT, INI_STR("amqp.timeout")) != 0) {
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "INI setting 'amqp.timeout' is deprecated; use 'amqp.read_timeout' instead");
if (strcmp(DEFAULT_READ_TIMEOUT, INI_STR("amqp.read_timeout")) == 0) {
zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), INI_FLT("amqp.timeout") TSRMLS_CC);
} else {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "INI setting 'amqp.read_timeout' will be used instead of 'amqp.timeout'");
zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), INI_FLT("amqp.read_timeout") TSRMLS_CC);
}
} else {
zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), INI_FLT("amqp.read_timeout") TSRMLS_CC);
}
}
zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("write_timeout"), INI_FLT("amqp.write_timeout") TSRMLS_CC);
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "write_timeout", sizeof("write_timeout"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_double(PHP5to7_MAYBE_DEREF(zdata));
if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'write_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
} else {
zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("write_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
}
}
zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("rpc_timeout"), INI_FLT("amqp.rpc_timeout") TSRMLS_CC);
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "rpc_timeout", sizeof("rpc_timeout"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_double(PHP5to7_MAYBE_DEREF(zdata));
if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'rpc_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
} else {
zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("rpc_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
}
}
zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("connect_timeout"), INI_FLT("amqp.connect_timeout") TSRMLS_CC);
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "connect_timeout", sizeof("connect_timeout"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_double(PHP5to7_MAYBE_DEREF(zdata));
if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'connect_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
} else {
zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("connect_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
}
}
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("channel_max"), INI_INT("amqp.channel_max") TSRMLS_CC);
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "channel_max", sizeof("channel_max"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_long(PHP5to7_MAYBE_DEREF(zdata));
if (Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0 || Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) > PHP_AMQP_MAX_CHANNELS) {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'channel_max' is out of range.", 0 TSRMLS_CC);
} else {
if(Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) == 0) {
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("channel_max"), PHP_AMQP_DEFAULT_CHANNEL_MAX TSRMLS_CC);
} else {
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("channel_max"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
}
}
}
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("frame_max"), INI_INT("amqp.frame_max") TSRMLS_CC);
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "frame_max", sizeof("frame_max"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_long(PHP5to7_MAYBE_DEREF(zdata));
if (Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0 || Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) > PHP_AMQP_MAX_FRAME) {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'frame_max' is out of range.", 0 TSRMLS_CC);
} else {
if(Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) == 0) {
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("frame_max"), PHP_AMQP_DEFAULT_FRAME_MAX TSRMLS_CC);
} else {
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("frame_max"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
}
}
}
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("heartbeat"), INI_INT("amqp.heartbeat") TSRMLS_CC);
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "heartbeat", sizeof("heartbeat"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_long(PHP5to7_MAYBE_DEREF(zdata));
if (Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0 || Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) > PHP_AMQP_MAX_HEARTBEAT) {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'heartbeat' is out of range.", 0 TSRMLS_CC);
} else {
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("heartbeat"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
}
}
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("sasl_method"), INI_INT("amqp.sasl_method") TSRMLS_CC);
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "sasl_method", sizeof("sasl_method"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_long(PHP5to7_MAYBE_DEREF(zdata));
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("sasl_method"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
}
PHP_AMQP_EXTRACT_CONNECTION_STR("cacert");
PHP_AMQP_EXTRACT_CONNECTION_STR("capath");
PHP_AMQP_EXTRACT_CONNECTION_BOOL("use_default_cacert");
PHP_AMQP_EXTRACT_CONNECTION_BOOL("use_default_capath");
PHP_AMQP_EXTRACT_CONNECTION_STR("key");
PHP_AMQP_EXTRACT_CONNECTION_STR("cert");
PHP_AMQP_EXTRACT_CONNECTION_BOOL("verify");
/* Pull the connection_name out of the $params array */
zdata = NULL;
if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "connection_name", sizeof("connection_name"), zdata)) {
SEPARATE_ZVAL(zdata);
convert_to_string(PHP5to7_MAYBE_DEREF(zdata));
}
if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) {
zend_update_property_string(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("connection_name"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
}
}
/* }}} */
/* {{{ proto amqp::isConnected()
check amqp connection */
static PHP_METHOD(amqp_connection_class, isConnected)
{
amqp_connection_object *connection;
PHP_AMQP_NOPARAMS();
/* Get the connection object out of the store */
connection = PHP_AMQP_GET_CONNECTION(getThis());
/* If the channel_connect is 1, we have a connection */
if (connection->connection_resource != NULL && connection->connection_resource->is_connected) {
RETURN_TRUE;
}
/* We have no connection */
RETURN_FALSE;
}
/* }}} */
/* {{{ proto amqp::connect()
create amqp connection */
static PHP_METHOD(amqp_connection_class, connect)
{
amqp_connection_object *connection;
PHP_AMQP_NOPARAMS();
/* Get the connection object out of the store */
connection = PHP_AMQP_GET_CONNECTION(getThis());
if (connection->connection_resource && connection->connection_resource->is_connected) {
if (connection->connection_resource->is_persistent) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to start transient connection while persistent transient one already established. Continue.");
}
RETURN_TRUE;
}
/* Actually connect this resource to the broker */
RETURN_BOOL(php_amqp_connect(connection, 0, INTERNAL_FUNCTION_PARAM_PASSTHRU));
}
/* }}} */
/* {{{ proto amqp::connect()
create amqp connection */
static PHP_METHOD(amqp_connection_class, pconnect)
{
amqp_connection_object *connection;
PHP_AMQP_NOPARAMS();
/* Get the connection object out of the store */
connection = PHP_AMQP_GET_CONNECTION(getThis());
if (connection->connection_resource && connection->connection_resource->is_connected) {
assert(connection->connection_resource != NULL);
if (!connection->connection_resource->is_persistent) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to start persistent connection while transient one already established. Continue.");
}
RETURN_TRUE;
}
/* Actually connect this resource to the broker or use stored connection */
RETURN_BOOL(php_amqp_connect(connection, 1, INTERNAL_FUNCTION_PARAM_PASSTHRU));
}
/* }}} */
/* {{{ proto amqp:pdisconnect()
destroy amqp persistent connection */
static PHP_METHOD(amqp_connection_class, pdisconnect)
{
amqp_connection_object *connection;
PHP_AMQP_NOPARAMS();
/* Get the connection object out of the store */
connection = PHP_AMQP_GET_CONNECTION(getThis());
if (!connection->connection_resource || !connection->connection_resource->is_connected) {
RETURN_TRUE;
}
assert(connection->connection_resource != NULL);
if (!connection->connection_resource->is_persistent) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to close persistent connection while transient one already established. Abort.");
RETURN_FALSE;
}
php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto amqp::disconnect()
destroy amqp connection */
static PHP_METHOD(amqp_connection_class, disconnect)
{
amqp_connection_object *connection;
PHP_AMQP_NOPARAMS();
/* Get the connection object out of the store */
connection = PHP_AMQP_GET_CONNECTION(getThis());
if (!connection->connection_resource || !connection->connection_resource->is_connected) {
RETURN_TRUE;
}
if (connection->connection_resource->is_persistent) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to close transient connection while persistent one already established. Abort.");
RETURN_FALSE;
}
assert(connection->connection_resource != NULL);
php_amqp_disconnect(connection->connection_resource TSRMLS_CC);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto amqp::reconnect()
recreate amqp connection */
static PHP_METHOD(amqp_connection_class, reconnect)
{
amqp_connection_object *connection;
PHP_AMQP_NOPARAMS();
/* Get the connection object out of the store */
connection = PHP_AMQP_GET_CONNECTION(getThis());
if (connection->connection_resource && connection->connection_resource->is_connected) {
assert(connection->connection_resource != NULL);
if (connection->connection_resource->is_persistent) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to reconnect persistent connection while transient one already established. Abort.");
RETURN_FALSE;
}
php_amqp_disconnect(connection->connection_resource TSRMLS_CC);
}
RETURN_BOOL(php_amqp_connect(connection, 0, INTERNAL_FUNCTION_PARAM_PASSTHRU));
}
/* }}} */
/* {{{ proto amqp::preconnect()
recreate amqp connection */
static PHP_METHOD(amqp_connection_class, preconnect)
{
amqp_connection_object *connection;
PHP_AMQP_NOPARAMS();
/* Get the connection object out of the store */
connection = PHP_AMQP_GET_CONNECTION(getThis());
if (connection->connection_resource && connection->connection_resource->is_connected) {
assert(connection->connection_resource != NULL);
if (!connection->connection_resource->is_persistent) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to reconnect transient connection while persistent one already established. Abort.");
RETURN_FALSE;
}
php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC);
}
RETURN_BOOL(php_amqp_connect(connection, 1, INTERNAL_FUNCTION_PARAM_PASSTHRU));
}
/* }}} */
/* {{{ proto amqp::sendHeartbeat()
Manual send heartbeat if it necessary */
static PHP_METHOD(amqp_connection_class, sendHeartbeat)
{
PHP5to7_READ_PROP_RV_PARAM_DECL;
amqp_connection_object *connection;
PHP_AMQP_NOPARAMS();
/* Get the connection object out of the store */
connection = PHP_AMQP_GET_CONNECTION(getThis());
if (connection->connection_resource && connection->connection_resource->is_connected) {
if (AMQP_STATUS_OK != amqp_send_heartbeat(connection->connection_resource->connection_state)) {
zend_throw_exception(amqp_connection_exception_class_entry, "Library error: error while send heartbeat", 0 TSRMLS_CC);
return;
}
} else {
zend_throw_exception(amqp_connection_exception_class_entry, "Error while try send heartbeat: not connected", 0 TSRMLS_CC);
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto amqp::getLogin()
get the login */
static PHP_METHOD(amqp_connection_class, getLogin)
{
PHP5to7_READ_PROP_RV_PARAM_DECL;
PHP_AMQP_NOPARAMS();
PHP_AMQP_RETURN_THIS_PROP("login");
}
/* }}} */
/* {{{ proto amqp::setLogin(string login)
set the login */
static PHP_METHOD(amqp_connection_class, setLogin)
{
char *login = NULL; PHP5to7_param_str_len_type_t login_len = 0;
/* Get the login from the method params */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &login, &login_len) == FAILURE) {
return;
}
/* Validate login length */
if (login_len > 128) {
zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'login' given, exceeds 128 characters limit.", 0 TSRMLS_CC);
return;
}
zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("login"), login, login_len TSRMLS_CC);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto amqp::getPassword()
get the password */
static PHP_METHOD(amqp_connection_class, getPassword)
{
PHP5to7_READ_PROP_RV_PARAM_DECL;
PHP_AMQP_NOPARAMS();
PHP_AMQP_RETURN_THIS_PROP("password");
}
/* }}} */
/* {{{ proto amqp::setPassword(string password)
set the password */
static PHP_METHOD(amqp_connection_class, setPassword)
{
char *password = NULL; PHP5to7_param_str_len_type_t password_len = 0;
/* Get the password from the method params */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &password, &password_len) == FAILURE) {
return;
}
/* Validate password length */
if (password_len > 128) {
zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'password' given, exceeds 128 characters limit.", 0 TSRMLS_CC);
return;
}
zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("password"), password, password_len TSRMLS_CC);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto amqp::getHost()
get the host */
static PHP_METHOD(amqp_connection_class, getHost)
{
PHP5to7_READ_PROP_RV_PARAM_DECL;
PHP_AMQP_NOPARAMS();
PHP_AMQP_RETURN_THIS_PROP("host");
}
/* }}} */
/* {{{ proto amqp::setHost(string host)
set the host */
static PHP_METHOD(amqp_connection_class, setHost)
{
char *host = NULL; PHP5to7_param_str_len_type_t host_len = 0;
/* Get the host from the method params */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &host, &host_len) == FAILURE) {
return;
}
/* Validate host length */
if (host_len > 1024) {
zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'host' given, exceeds 1024 character limit.", 0 TSRMLS_CC);
return;
}
zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("host"), host, host_len TSRMLS_CC);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto amqp::getPort()
get the port */
static PHP_METHOD(amqp_connection_class, getPort)
{
PHP5to7_READ_PROP_RV_PARAM_DECL;
PHP_AMQP_NOPARAMS();
PHP_AMQP_RETURN_THIS_PROP("port");
}
/* }}} */
/* {{{ proto amqp::setPort(mixed port)
set the port */
static PHP_METHOD(amqp_connection_class, setPort)
{
zval *zvalPort;
int port;
/* Get the port from the method params */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &zvalPort) == FAILURE) {
return;
}
/* Parse out the port*/
switch (Z_TYPE_P(zvalPort)) {
case IS_DOUBLE:
port = (int)Z_DVAL_P(zvalPort);
break;
case IS_LONG:
port = (int)Z_LVAL_P(zvalPort);
break;
case IS_STRING:
convert_to_long(zvalPort);
port = (int)Z_LVAL_P(zvalPort);
break;
default:
port = 0;
}
/* Check the port value */
if (port <= 0 || port > 65535) {
zend_throw_exception(amqp_connection_exception_class_entry, "Invalid port given. Value must be between 1 and 65535.", 0 TSRMLS_CC);
return;
}
zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("port"), port TSRMLS_CC);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto amqp::getVhost()
get the vhost */
static PHP_METHOD(amqp_connection_class, getVhost)
{
PHP5to7_READ_PROP_RV_PARAM_DECL;
PHP_AMQP_NOPARAMS();
PHP_AMQP_RETURN_THIS_PROP("vhost");
}
/* }}} */
/* {{{ proto amqp::setVhost(string vhost)
set the vhost */
static PHP_METHOD(amqp_connection_class, setVhost)
{
char *vhost = NULL; PHP5to7_param_str_len_type_t vhost_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &vhost, &vhost_len) == FAILURE) {
return;
}
/* Validate vhost length */
if (vhost_len > 128) {
zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'vhost' exceeds 128 characters limit.", 0 TSRMLS_CC);
return;
}
zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("vhost"), vhost, vhost_len TSRMLS_CC);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto amqp::getTimeout()
@deprecated
get the timeout */
static PHP_METHOD(amqp_connection_class, getTimeout)
{
php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead");
PHP5to7_READ_PROP_RV_PARAM_DECL;
PHP_AMQP_NOPARAMS();
PHP_AMQP_RETURN_THIS_PROP("read_timeout");
}
/* }}} */