mongrel 1.0.5 → 1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mongrel might be problematic. Click here for more details.

@@ -1,38 +0,0 @@
1
-
2
- #include "tst.h"
3
- #include <stdio.h>
4
- #include <stdlib.h>
5
-
6
- int tst_grow_node_free_list(struct tst *tst)
7
- {
8
- struct node *current_node;
9
- struct node_lines *new_line;
10
- int i;
11
-
12
-
13
- if((new_line = (struct node_lines *) malloc(sizeof(struct node_lines))) == NULL)
14
- return TST_ERROR;
15
-
16
- if((new_line->node_line = (struct node *)
17
- calloc(tst->node_line_width, sizeof(struct node))) == NULL)
18
- {
19
- free(new_line);
20
- return TST_ERROR;
21
- }
22
- else
23
- {
24
- new_line->next = tst->node_lines;
25
- tst->node_lines = new_line;
26
- }
27
-
28
- current_node = tst->node_lines->node_line;
29
- tst->free_list = current_node;
30
- for (i = 1; i < tst->node_line_width; i++)
31
- {
32
- current_node->middle = &(tst->node_lines->node_line[i]);
33
- current_node = current_node->middle;
34
- }
35
- current_node->middle = NULL;
36
- return 1;
37
- }
38
-
@@ -1,41 +0,0 @@
1
-
2
- #include "tst.h"
3
- #include <stdio.h>
4
- #include <stdlib.h>
5
-
6
- struct tst *tst_init(int width)
7
- {
8
- struct tst *tst;
9
- struct node *current_node;
10
- int i;
11
-
12
-
13
- if((tst = (struct tst *) calloc(1, sizeof(struct tst))) == NULL)
14
- return NULL;
15
-
16
- if ((tst->node_lines = (struct node_lines *) calloc(1, sizeof(struct node_lines))) == NULL)
17
- {
18
- free(tst);
19
- return NULL;
20
- }
21
-
22
- tst->node_line_width = width;
23
- tst->node_lines->next = NULL;
24
- if ((tst->node_lines->node_line = (struct node *) calloc(width, sizeof(struct node))) == NULL)
25
- {
26
- free(tst->node_lines);
27
- free(tst);
28
- return NULL;
29
- }
30
-
31
- current_node = tst->node_lines->node_line;
32
- tst->free_list = current_node;
33
- for (i = 1; i < width; i++)
34
- {
35
- current_node->middle = &(tst->node_lines->node_line[i]);
36
- current_node = current_node->middle;
37
- }
38
- current_node->middle = NULL;
39
- return tst;
40
- }
41
-
@@ -1,218 +0,0 @@
1
-
2
- #include "tst.h"
3
- #include <stdio.h>
4
- #include <stdlib.h>
5
- #include <string.h>
6
-
7
- int tst_grow_node_free_list(struct tst *tst);
8
- int tst_insert(unsigned char *key, void *data, struct tst *tst, int option, void **exist_ptr)
9
- {
10
- struct node *current_node;
11
- struct node *new_node_tree_begin = NULL;
12
- struct node *new_node;
13
- int key_index;
14
- int perform_loop = 1;
15
-
16
- if (key == NULL)
17
- return TST_NULL_KEY;
18
-
19
- if(key[0] == 0)
20
- return TST_NULL_KEY;
21
-
22
- if(tst->head[(int)key[0]] == NULL)
23
- {
24
-
25
- if(tst->free_list == NULL)
26
- {
27
- if(tst_grow_node_free_list(tst) != 1)
28
- return TST_ERROR;
29
- }
30
- tst->head[(int)key[0]] = tst->free_list;
31
-
32
- tst->free_list = tst->free_list->middle;
33
- current_node = tst->head[(int)key[0]];
34
- current_node->value = key[1];
35
- if(key[1] == 0)
36
- {
37
- current_node->middle = data;
38
- return TST_OK;
39
- }
40
- else
41
- perform_loop = 0;
42
- }
43
-
44
- current_node = tst->head[(int)key[0]];
45
- key_index = 1;
46
- while(perform_loop == 1)
47
- {
48
- if(key[key_index] == current_node->value)
49
- {
50
-
51
- if(key[key_index] == 0)
52
- {
53
- if (option == TST_REPLACE)
54
- {
55
- if (exist_ptr != NULL)
56
- *exist_ptr = current_node->middle;
57
-
58
- current_node->middle = data;
59
- return TST_OK;
60
- }
61
- else
62
- {
63
- if (exist_ptr != NULL)
64
- *exist_ptr = current_node->middle;
65
- return TST_DUPLICATE_KEY;
66
- }
67
- }
68
- else
69
- {
70
- if(current_node->middle == NULL)
71
- {
72
-
73
- if(tst->free_list == NULL)
74
- {
75
- if(tst_grow_node_free_list(tst) != 1)
76
- return TST_ERROR;
77
- }
78
- current_node->middle = tst->free_list;
79
-
80
- tst->free_list = tst->free_list->middle;
81
- new_node_tree_begin = current_node;
82
- current_node = current_node->middle;
83
- current_node->value = key[key_index];
84
- break;
85
- }
86
- else
87
- {
88
- current_node = current_node->middle;
89
- key_index++;
90
- continue;
91
- }
92
- }
93
- }
94
- if(key[key_index] == 0)
95
- {
96
- if(tst->free_list == NULL)
97
- {
98
- if(tst_grow_node_free_list(tst) != 1)
99
- return TST_ERROR;
100
- }
101
- new_node = tst->free_list;
102
- tst->free_list = tst->free_list->middle;
103
-
104
- memcpy((void*)new_node, (void*)current_node, sizeof(struct node));
105
- current_node->value = 0;
106
- if(new_node->value < 64)
107
- {
108
- current_node->left = new_node;
109
- current_node->right = '\0';
110
- }
111
- else
112
- {
113
- current_node->left = '\0';
114
- current_node->right = new_node;
115
- }
116
-
117
- current_node->middle = data;
118
- return TST_OK;
119
- }
120
-
121
- if( ((current_node->value == 0) && (key[key_index] < 64)) ||
122
- ((current_node->value != 0) && (key[key_index] <
123
- current_node->value)) )
124
- {
125
-
126
- if (current_node->left == NULL)
127
- {
128
-
129
- if(tst->free_list == NULL)
130
- {
131
- if(tst_grow_node_free_list(tst) != 1)
132
- return TST_ERROR;
133
- }
134
- current_node->left = tst->free_list;
135
-
136
- tst->free_list = tst->free_list->middle;
137
- new_node_tree_begin = current_node;
138
- current_node = current_node->left;
139
- current_node->value = key[key_index];
140
- if(key[key_index] == 0)
141
- {
142
- current_node->middle = data;
143
- return TST_OK;
144
- }
145
- else
146
- break;
147
- }
148
- else
149
- {
150
- current_node = current_node->left;
151
- continue;
152
- }
153
- }
154
- else
155
- {
156
-
157
- if (current_node->right == NULL)
158
- {
159
-
160
- if(tst->free_list == NULL)
161
- {
162
- if(tst_grow_node_free_list(tst) != 1)
163
- return TST_ERROR;
164
- }
165
- current_node->right = tst->free_list;
166
-
167
- tst->free_list = tst->free_list->middle;
168
- new_node_tree_begin = current_node;
169
- current_node = current_node->right;
170
- current_node->value = key[key_index];
171
- break;
172
- }
173
- else
174
- {
175
- current_node = current_node->right;
176
- continue;
177
- }
178
- }
179
- }
180
-
181
- do
182
- {
183
- key_index++;
184
-
185
- if(tst->free_list == NULL)
186
- {
187
- if(tst_grow_node_free_list(tst) != 1)
188
- {
189
- current_node = new_node_tree_begin->middle;
190
-
191
- while (current_node->middle != NULL)
192
- current_node = current_node->middle;
193
-
194
- current_node->middle = tst->free_list;
195
- tst->free_list = new_node_tree_begin->middle;
196
- new_node_tree_begin->middle = NULL;
197
-
198
- return TST_ERROR;
199
- }
200
- }
201
-
202
-
203
- if(tst->free_list == NULL)
204
- {
205
- if(tst_grow_node_free_list(tst) != 1)
206
- return TST_ERROR;
207
- }
208
- current_node->middle = tst->free_list;
209
-
210
- tst->free_list = tst->free_list->middle;
211
- current_node = current_node->middle;
212
- current_node->value = key[key_index];
213
- } while(key[key_index] !=0);
214
-
215
- current_node->middle = data;
216
- return TST_OK;
217
- }
218
-
@@ -1,73 +0,0 @@
1
-
2
- #include "tst.h"
3
- #include <stdio.h>
4
- #include <stdlib.h>
5
- #include <assert.h>
6
-
7
-
8
- void *tst_search(const unsigned char *key, struct tst *tst, int option,
9
- unsigned int *match_len)
10
- {
11
- struct node *current_node;
12
- struct node *longest_match = NULL;
13
- unsigned int longest_match_len = 0;
14
- int key_index;
15
-
16
- assert(key != NULL && "key can't be NULL");
17
- assert(tst != NULL && "tst can't be NULL");
18
-
19
- if (key[0] == 0)
20
- return NULL;
21
-
22
- if (tst->head[(int) key[0]] == NULL)
23
- return NULL;
24
-
25
- if (match_len)
26
- *match_len = 0;
27
-
28
- current_node = tst->head[(int) key[0]];
29
- key_index = 1;
30
-
31
- while (current_node != NULL) {
32
- if (key[key_index] == current_node->value) {
33
- if (current_node->value == 0) {
34
- if (match_len)
35
- *match_len = key_index;
36
- return current_node->middle;
37
- } else {
38
- current_node = current_node->middle;
39
- key_index++;
40
- continue;
41
- }
42
- } else {
43
- if (current_node->value == 0) {
44
- if (option & TST_LONGEST_MATCH) {
45
- longest_match = current_node->middle;
46
- longest_match_len = key_index;
47
- }
48
-
49
- if (key[key_index] < 64) {
50
- current_node = current_node->left;
51
- continue;
52
- } else {
53
- current_node = current_node->right;
54
- continue;
55
- }
56
- } else {
57
- if (key[key_index] < current_node->value) {
58
- current_node = current_node->left;
59
- continue;
60
- } else {
61
- current_node = current_node->right;
62
- continue;
63
- }
64
- }
65
- }
66
- }
67
-
68
- if (match_len)
69
- *match_len = longest_match_len;
70
-
71
- return longest_match;
72
-
73
- }
@@ -1,34 +0,0 @@
1
- require 'thread'
2
-
3
- # monkey patch Mutex so it does not leak memory.
4
- class Mutex
5
-
6
- def lock
7
- while (Thread.critical = true; @locked)
8
- @waiting.unshift Thread.current
9
- Thread.stop
10
- end
11
- @locked = true
12
- Thread.critical = false
13
- self
14
- end
15
-
16
- def unlock
17
- return unless @locked
18
- Thread.critical = true
19
- @locked = false
20
- begin
21
- t = @waiting.pop
22
- t.wakeup if t
23
- rescue ThreadError
24
- retry
25
- end
26
- Thread.critical = false
27
- begin
28
- t.run if t
29
- rescue ThreadError
30
- end
31
- self
32
- end
33
-
34
- end
@@ -1,39 +0,0 @@
1
-
2
- # Minimal test to help debug JRuby socket issues
3
-
4
- require 'socket'
5
-
6
- @server = Thread.new do
7
- server_socket = TCPServer.new('0.0.0.0', 10101)
8
- this_client = server_socket.accept
9
- 4.times do |n|
10
- begin
11
- data = this_client.readpartial(2)
12
- puts "Server got: #{data}"
13
- if n == 0
14
- this_client.close
15
- puts "Server closed the client"
16
- end
17
- rescue IOError => e
18
- puts "Server has: #{e.inspect}"
19
- end
20
- sleep(1)
21
- end
22
- server_socket.close
23
- end
24
-
25
- sleep(3)
26
- client_socket = TCPSocket.new('0.0.0.0', 10101)
27
- 4.times do |n|
28
- string = "X#{n}"
29
- begin
30
- client_socket.write(string)
31
- puts "Client said: #{string}"
32
- rescue Errno::EPIPE => e
33
- puts "Client has: #{e.inspect}"
34
- end
35
- sleep(1)
36
- end
37
- client_socket.close
38
-
39
- @server.join