@@ -582,109 +582,6 @@ ngx_http_lua_shdict_get_keys(lua_State *L)
582
582
}
583
583
584
584
585
- ngx_int_t
586
- ngx_http_lua_shared_dict_get (ngx_shm_zone_t * zone , u_char * key_data ,
587
- size_t key_len , ngx_http_lua_value_t * value )
588
- {
589
- u_char * data ;
590
- size_t len ;
591
- uint32_t hash ;
592
- ngx_int_t rc ;
593
- ngx_http_lua_shdict_ctx_t * ctx ;
594
- ngx_http_lua_shdict_node_t * sd ;
595
-
596
- if (zone == NULL ) {
597
- return NGX_ERROR ;
598
- }
599
-
600
- hash = ngx_crc32_short (key_data , key_len );
601
-
602
- ctx = zone -> data ;
603
-
604
- ngx_shmtx_lock (& ctx -> shpool -> mutex );
605
-
606
- rc = ngx_http_lua_shdict_lookup (zone , hash , key_data , key_len , & sd );
607
-
608
- dd ("shdict lookup returned %d" , (int ) rc );
609
-
610
- if (rc == NGX_DECLINED || rc == NGX_DONE ) {
611
- ngx_shmtx_unlock (& ctx -> shpool -> mutex );
612
-
613
- return rc ;
614
- }
615
-
616
- /* rc == NGX_OK */
617
-
618
- value -> type = sd -> value_type ;
619
-
620
- dd ("type: %d" , (int ) value -> type );
621
-
622
- data = sd -> data + sd -> key_len ;
623
- len = (size_t ) sd -> value_len ;
624
-
625
- switch (value -> type ) {
626
-
627
- case SHDICT_TSTRING :
628
-
629
- if (value -> value .s .data == NULL || value -> value .s .len == 0 ) {
630
- ngx_log_error (NGX_LOG_ERR , ngx_cycle -> log , 0 , "no string buffer "
631
- "initialized" );
632
- ngx_shmtx_unlock (& ctx -> shpool -> mutex );
633
- return NGX_ERROR ;
634
- }
635
-
636
- if (len > value -> value .s .len ) {
637
- len = value -> value .s .len ;
638
-
639
- } else {
640
- value -> value .s .len = len ;
641
- }
642
-
643
- ngx_memcpy (value -> value .s .data , data , len );
644
- break ;
645
-
646
- case SHDICT_TNUMBER :
647
-
648
- if (len != sizeof (double )) {
649
- ngx_log_error (NGX_LOG_ERR , ngx_cycle -> log , 0 , "bad lua number "
650
- "value size found for key %*s: %lu" , key_len ,
651
- key_data , (unsigned long ) len );
652
-
653
- ngx_shmtx_unlock (& ctx -> shpool -> mutex );
654
- return NGX_ERROR ;
655
- }
656
-
657
- ngx_memcpy (& value -> value .b , data , len );
658
- break ;
659
-
660
- case SHDICT_TBOOLEAN :
661
-
662
- if (len != sizeof (u_char )) {
663
- ngx_log_error (NGX_LOG_ERR , ngx_cycle -> log , 0 , "bad lua boolean "
664
- "value size found for key %*s: %lu" , key_len ,
665
- key_data , (unsigned long ) len );
666
-
667
- ngx_shmtx_unlock (& ctx -> shpool -> mutex );
668
- return NGX_ERROR ;
669
- }
670
-
671
- value -> value .b = * data ;
672
- break ;
673
-
674
- default :
675
- ngx_log_error (NGX_LOG_ERR , ngx_cycle -> log , 0 , "bad lua value type "
676
- "found for key %*s: %d" , key_len , key_data ,
677
- (int ) value -> type );
678
-
679
- ngx_shmtx_unlock (& ctx -> shpool -> mutex );
680
- return NGX_ERROR ;
681
- }
682
-
683
- ngx_shmtx_unlock (& ctx -> shpool -> mutex );
684
- return NGX_OK ;
685
- }
686
-
687
-
688
585
static int
689
586
ngx_http_lua_shdict_lpush (lua_State * L )
690
587
{
0 commit comments