Codebase list beanstalkd / 1ab8312
Imported Upstream version 1.5 Serafeim Zanikolas 12 years ago
113 changed file(s) with 5268 addition(s) and 14473 deletion(s). Raw diff Collapse all Expand all
0 *.o
1 vers.c
2 ct/_*
3 beanstalkd
4 beanstalkd-*.tar.gz
5 NEWS.md
+0
-674
COPYING less more
0 GNU GENERAL PUBLIC LICENSE
1 Version 3, 29 June 2007
2
3 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
4 Everyone is permitted to copy and distribute verbatim copies
5 of this license document, but changing it is not allowed.
6
7 Preamble
8
9 The GNU General Public License is a free, copyleft license for
10 software and other kinds of works.
11
12 The licenses for most software and other practical works are designed
13 to take away your freedom to share and change the works. By contrast,
14 the GNU General Public License is intended to guarantee your freedom to
15 share and change all versions of a program--to make sure it remains free
16 software for all its users. We, the Free Software Foundation, use the
17 GNU General Public License for most of our software; it applies also to
18 any other work released this way by its authors. You can apply it to
19 your programs, too.
20
21 When we speak of free software, we are referring to freedom, not
22 price. Our General Public Licenses are designed to make sure that you
23 have the freedom to distribute copies of free software (and charge for
24 them if you wish), that you receive source code or can get it if you
25 want it, that you can change the software or use pieces of it in new
26 free programs, and that you know you can do these things.
27
28 To protect your rights, we need to prevent others from denying you
29 these rights or asking you to surrender the rights. Therefore, you have
30 certain responsibilities if you distribute copies of the software, or if
31 you modify it: responsibilities to respect the freedom of others.
32
33 For example, if you distribute copies of such a program, whether
34 gratis or for a fee, you must pass on to the recipients the same
35 freedoms that you received. You must make sure that they, too, receive
36 or can get the source code. And you must show them these terms so they
37 know their rights.
38
39 Developers that use the GNU GPL protect your rights with two steps:
40 (1) assert copyright on the software, and (2) offer you this License
41 giving you legal permission to copy, distribute and/or modify it.
42
43 For the developers' and authors' protection, the GPL clearly explains
44 that there is no warranty for this free software. For both users' and
45 authors' sake, the GPL requires that modified versions be marked as
46 changed, so that their problems will not be attributed erroneously to
47 authors of previous versions.
48
49 Some devices are designed to deny users access to install or run
50 modified versions of the software inside them, although the manufacturer
51 can do so. This is fundamentally incompatible with the aim of
52 protecting users' freedom to change the software. The systematic
53 pattern of such abuse occurs in the area of products for individuals to
54 use, which is precisely where it is most unacceptable. Therefore, we
55 have designed this version of the GPL to prohibit the practice for those
56 products. If such problems arise substantially in other domains, we
57 stand ready to extend this provision to those domains in future versions
58 of the GPL, as needed to protect the freedom of users.
59
60 Finally, every program is threatened constantly by software patents.
61 States should not allow patents to restrict development and use of
62 software on general-purpose computers, but in those that do, we wish to
63 avoid the special danger that patents applied to a free program could
64 make it effectively proprietary. To prevent this, the GPL assures that
65 patents cannot be used to render the program non-free.
66
67 The precise terms and conditions for copying, distribution and
68 modification follow.
69
70 TERMS AND CONDITIONS
71
72 0. Definitions.
73
74 "This License" refers to version 3 of the GNU General Public License.
75
76 "Copyright" also means copyright-like laws that apply to other kinds of
77 works, such as semiconductor masks.
78
79 "The Program" refers to any copyrightable work licensed under this
80 License. Each licensee is addressed as "you". "Licensees" and
81 "recipients" may be individuals or organizations.
82
83 To "modify" a work means to copy from or adapt all or part of the work
84 in a fashion requiring copyright permission, other than the making of an
85 exact copy. The resulting work is called a "modified version" of the
86 earlier work or a work "based on" the earlier work.
87
88 A "covered work" means either the unmodified Program or a work based
89 on the Program.
90
91 To "propagate" a work means to do anything with it that, without
92 permission, would make you directly or secondarily liable for
93 infringement under applicable copyright law, except executing it on a
94 computer or modifying a private copy. Propagation includes copying,
95 distribution (with or without modification), making available to the
96 public, and in some countries other activities as well.
97
98 To "convey" a work means any kind of propagation that enables other
99 parties to make or receive copies. Mere interaction with a user through
100 a computer network, with no transfer of a copy, is not conveying.
101
102 An interactive user interface displays "Appropriate Legal Notices"
103 to the extent that it includes a convenient and prominently visible
104 feature that (1) displays an appropriate copyright notice, and (2)
105 tells the user that there is no warranty for the work (except to the
106 extent that warranties are provided), that licensees may convey the
107 work under this License, and how to view a copy of this License. If
108 the interface presents a list of user commands or options, such as a
109 menu, a prominent item in the list meets this criterion.
110
111 1. Source Code.
112
113 The "source code" for a work means the preferred form of the work
114 for making modifications to it. "Object code" means any non-source
115 form of a work.
116
117 A "Standard Interface" means an interface that either is an official
118 standard defined by a recognized standards body, or, in the case of
119 interfaces specified for a particular programming language, one that
120 is widely used among developers working in that language.
121
122 The "System Libraries" of an executable work include anything, other
123 than the work as a whole, that (a) is included in the normal form of
124 packaging a Major Component, but which is not part of that Major
125 Component, and (b) serves only to enable use of the work with that
126 Major Component, or to implement a Standard Interface for which an
127 implementation is available to the public in source code form. A
128 "Major Component", in this context, means a major essential component
129 (kernel, window system, and so on) of the specific operating system
130 (if any) on which the executable work runs, or a compiler used to
131 produce the work, or an object code interpreter used to run it.
132
133 The "Corresponding Source" for a work in object code form means all
134 the source code needed to generate, install, and (for an executable
135 work) run the object code and to modify the work, including scripts to
136 control those activities. However, it does not include the work's
137 System Libraries, or general-purpose tools or generally available free
138 programs which are used unmodified in performing those activities but
139 which are not part of the work. For example, Corresponding Source
140 includes interface definition files associated with source files for
141 the work, and the source code for shared libraries and dynamically
142 linked subprograms that the work is specifically designed to require,
143 such as by intimate data communication or control flow between those
144 subprograms and other parts of the work.
145
146 The Corresponding Source need not include anything that users
147 can regenerate automatically from other parts of the Corresponding
148 Source.
149
150 The Corresponding Source for a work in source code form is that
151 same work.
152
153 2. Basic Permissions.
154
155 All rights granted under this License are granted for the term of
156 copyright on the Program, and are irrevocable provided the stated
157 conditions are met. This License explicitly affirms your unlimited
158 permission to run the unmodified Program. The output from running a
159 covered work is covered by this License only if the output, given its
160 content, constitutes a covered work. This License acknowledges your
161 rights of fair use or other equivalent, as provided by copyright law.
162
163 You may make, run and propagate covered works that you do not
164 convey, without conditions so long as your license otherwise remains
165 in force. You may convey covered works to others for the sole purpose
166 of having them make modifications exclusively for you, or provide you
167 with facilities for running those works, provided that you comply with
168 the terms of this License in conveying all material for which you do
169 not control copyright. Those thus making or running the covered works
170 for you must do so exclusively on your behalf, under your direction
171 and control, on terms that prohibit them from making any copies of
172 your copyrighted material outside their relationship with you.
173
174 Conveying under any other circumstances is permitted solely under
175 the conditions stated below. Sublicensing is not allowed; section 10
176 makes it unnecessary.
177
178 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
179
180 No covered work shall be deemed part of an effective technological
181 measure under any applicable law fulfilling obligations under article
182 11 of the WIPO copyright treaty adopted on 20 December 1996, or
183 similar laws prohibiting or restricting circumvention of such
184 measures.
185
186 When you convey a covered work, you waive any legal power to forbid
187 circumvention of technological measures to the extent such circumvention
188 is effected by exercising rights under this License with respect to
189 the covered work, and you disclaim any intention to limit operation or
190 modification of the work as a means of enforcing, against the work's
191 users, your or third parties' legal rights to forbid circumvention of
192 technological measures.
193
194 4. Conveying Verbatim Copies.
195
196 You may convey verbatim copies of the Program's source code as you
197 receive it, in any medium, provided that you conspicuously and
198 appropriately publish on each copy an appropriate copyright notice;
199 keep intact all notices stating that this License and any
200 non-permissive terms added in accord with section 7 apply to the code;
201 keep intact all notices of the absence of any warranty; and give all
202 recipients a copy of this License along with the Program.
203
204 You may charge any price or no price for each copy that you convey,
205 and you may offer support or warranty protection for a fee.
206
207 5. Conveying Modified Source Versions.
208
209 You may convey a work based on the Program, or the modifications to
210 produce it from the Program, in the form of source code under the
211 terms of section 4, provided that you also meet all of these conditions:
212
213 a) The work must carry prominent notices stating that you modified
214 it, and giving a relevant date.
215
216 b) The work must carry prominent notices stating that it is
217 released under this License and any conditions added under section
218 7. This requirement modifies the requirement in section 4 to
219 "keep intact all notices".
220
221 c) You must license the entire work, as a whole, under this
222 License to anyone who comes into possession of a copy. This
223 License will therefore apply, along with any applicable section 7
224 additional terms, to the whole of the work, and all its parts,
225 regardless of how they are packaged. This License gives no
226 permission to license the work in any other way, but it does not
227 invalidate such permission if you have separately received it.
228
229 d) If the work has interactive user interfaces, each must display
230 Appropriate Legal Notices; however, if the Program has interactive
231 interfaces that do not display Appropriate Legal Notices, your
232 work need not make them do so.
233
234 A compilation of a covered work with other separate and independent
235 works, which are not by their nature extensions of the covered work,
236 and which are not combined with it such as to form a larger program,
237 in or on a volume of a storage or distribution medium, is called an
238 "aggregate" if the compilation and its resulting copyright are not
239 used to limit the access or legal rights of the compilation's users
240 beyond what the individual works permit. Inclusion of a covered work
241 in an aggregate does not cause this License to apply to the other
242 parts of the aggregate.
243
244 6. Conveying Non-Source Forms.
245
246 You may convey a covered work in object code form under the terms
247 of sections 4 and 5, provided that you also convey the
248 machine-readable Corresponding Source under the terms of this License,
249 in one of these ways:
250
251 a) Convey the object code in, or embodied in, a physical product
252 (including a physical distribution medium), accompanied by the
253 Corresponding Source fixed on a durable physical medium
254 customarily used for software interchange.
255
256 b) Convey the object code in, or embodied in, a physical product
257 (including a physical distribution medium), accompanied by a
258 written offer, valid for at least three years and valid for as
259 long as you offer spare parts or customer support for that product
260 model, to give anyone who possesses the object code either (1) a
261 copy of the Corresponding Source for all the software in the
262 product that is covered by this License, on a durable physical
263 medium customarily used for software interchange, for a price no
264 more than your reasonable cost of physically performing this
265 conveying of source, or (2) access to copy the
266 Corresponding Source from a network server at no charge.
267
268 c) Convey individual copies of the object code with a copy of the
269 written offer to provide the Corresponding Source. This
270 alternative is allowed only occasionally and noncommercially, and
271 only if you received the object code with such an offer, in accord
272 with subsection 6b.
273
274 d) Convey the object code by offering access from a designated
275 place (gratis or for a charge), and offer equivalent access to the
276 Corresponding Source in the same way through the same place at no
277 further charge. You need not require recipients to copy the
278 Corresponding Source along with the object code. If the place to
279 copy the object code is a network server, the Corresponding Source
280 may be on a different server (operated by you or a third party)
281 that supports equivalent copying facilities, provided you maintain
282 clear directions next to the object code saying where to find the
283 Corresponding Source. Regardless of what server hosts the
284 Corresponding Source, you remain obligated to ensure that it is
285 available for as long as needed to satisfy these requirements.
286
287 e) Convey the object code using peer-to-peer transmission, provided
288 you inform other peers where the object code and Corresponding
289 Source of the work are being offered to the general public at no
290 charge under subsection 6d.
291
292 A separable portion of the object code, whose source code is excluded
293 from the Corresponding Source as a System Library, need not be
294 included in conveying the object code work.
295
296 A "User Product" is either (1) a "consumer product", which means any
297 tangible personal property which is normally used for personal, family,
298 or household purposes, or (2) anything designed or sold for incorporation
299 into a dwelling. In determining whether a product is a consumer product,
300 doubtful cases shall be resolved in favor of coverage. For a particular
301 product received by a particular user, "normally used" refers to a
302 typical or common use of that class of product, regardless of the status
303 of the particular user or of the way in which the particular user
304 actually uses, or expects or is expected to use, the product. A product
305 is a consumer product regardless of whether the product has substantial
306 commercial, industrial or non-consumer uses, unless such uses represent
307 the only significant mode of use of the product.
308
309 "Installation Information" for a User Product means any methods,
310 procedures, authorization keys, or other information required to install
311 and execute modified versions of a covered work in that User Product from
312 a modified version of its Corresponding Source. The information must
313 suffice to ensure that the continued functioning of the modified object
314 code is in no case prevented or interfered with solely because
315 modification has been made.
316
317 If you convey an object code work under this section in, or with, or
318 specifically for use in, a User Product, and the conveying occurs as
319 part of a transaction in which the right of possession and use of the
320 User Product is transferred to the recipient in perpetuity or for a
321 fixed term (regardless of how the transaction is characterized), the
322 Corresponding Source conveyed under this section must be accompanied
323 by the Installation Information. But this requirement does not apply
324 if neither you nor any third party retains the ability to install
325 modified object code on the User Product (for example, the work has
326 been installed in ROM).
327
328 The requirement to provide Installation Information does not include a
329 requirement to continue to provide support service, warranty, or updates
330 for a work that has been modified or installed by the recipient, or for
331 the User Product in which it has been modified or installed. Access to a
332 network may be denied when the modification itself materially and
333 adversely affects the operation of the network or violates the rules and
334 protocols for communication across the network.
335
336 Corresponding Source conveyed, and Installation Information provided,
337 in accord with this section must be in a format that is publicly
338 documented (and with an implementation available to the public in
339 source code form), and must require no special password or key for
340 unpacking, reading or copying.
341
342 7. Additional Terms.
343
344 "Additional permissions" are terms that supplement the terms of this
345 License by making exceptions from one or more of its conditions.
346 Additional permissions that are applicable to the entire Program shall
347 be treated as though they were included in this License, to the extent
348 that they are valid under applicable law. If additional permissions
349 apply only to part of the Program, that part may be used separately
350 under those permissions, but the entire Program remains governed by
351 this License without regard to the additional permissions.
352
353 When you convey a copy of a covered work, you may at your option
354 remove any additional permissions from that copy, or from any part of
355 it. (Additional permissions may be written to require their own
356 removal in certain cases when you modify the work.) You may place
357 additional permissions on material, added by you to a covered work,
358 for which you have or can give appropriate copyright permission.
359
360 Notwithstanding any other provision of this License, for material you
361 add to a covered work, you may (if authorized by the copyright holders of
362 that material) supplement the terms of this License with terms:
363
364 a) Disclaiming warranty or limiting liability differently from the
365 terms of sections 15 and 16 of this License; or
366
367 b) Requiring preservation of specified reasonable legal notices or
368 author attributions in that material or in the Appropriate Legal
369 Notices displayed by works containing it; or
370
371 c) Prohibiting misrepresentation of the origin of that material, or
372 requiring that modified versions of such material be marked in
373 reasonable ways as different from the original version; or
374
375 d) Limiting the use for publicity purposes of names of licensors or
376 authors of the material; or
377
378 e) Declining to grant rights under trademark law for use of some
379 trade names, trademarks, or service marks; or
380
381 f) Requiring indemnification of licensors and authors of that
382 material by anyone who conveys the material (or modified versions of
383 it) with contractual assumptions of liability to the recipient, for
384 any liability that these contractual assumptions directly impose on
385 those licensors and authors.
386
387 All other non-permissive additional terms are considered "further
388 restrictions" within the meaning of section 10. If the Program as you
389 received it, or any part of it, contains a notice stating that it is
390 governed by this License along with a term that is a further
391 restriction, you may remove that term. If a license document contains
392 a further restriction but permits relicensing or conveying under this
393 License, you may add to a covered work material governed by the terms
394 of that license document, provided that the further restriction does
395 not survive such relicensing or conveying.
396
397 If you add terms to a covered work in accord with this section, you
398 must place, in the relevant source files, a statement of the
399 additional terms that apply to those files, or a notice indicating
400 where to find the applicable terms.
401
402 Additional terms, permissive or non-permissive, may be stated in the
403 form of a separately written license, or stated as exceptions;
404 the above requirements apply either way.
405
406 8. Termination.
407
408 You may not propagate or modify a covered work except as expressly
409 provided under this License. Any attempt otherwise to propagate or
410 modify it is void, and will automatically terminate your rights under
411 this License (including any patent licenses granted under the third
412 paragraph of section 11).
413
414 However, if you cease all violation of this License, then your
415 license from a particular copyright holder is reinstated (a)
416 provisionally, unless and until the copyright holder explicitly and
417 finally terminates your license, and (b) permanently, if the copyright
418 holder fails to notify you of the violation by some reasonable means
419 prior to 60 days after the cessation.
420
421 Moreover, your license from a particular copyright holder is
422 reinstated permanently if the copyright holder notifies you of the
423 violation by some reasonable means, this is the first time you have
424 received notice of violation of this License (for any work) from that
425 copyright holder, and you cure the violation prior to 30 days after
426 your receipt of the notice.
427
428 Termination of your rights under this section does not terminate the
429 licenses of parties who have received copies or rights from you under
430 this License. If your rights have been terminated and not permanently
431 reinstated, you do not qualify to receive new licenses for the same
432 material under section 10.
433
434 9. Acceptance Not Required for Having Copies.
435
436 You are not required to accept this License in order to receive or
437 run a copy of the Program. Ancillary propagation of a covered work
438 occurring solely as a consequence of using peer-to-peer transmission
439 to receive a copy likewise does not require acceptance. However,
440 nothing other than this License grants you permission to propagate or
441 modify any covered work. These actions infringe copyright if you do
442 not accept this License. Therefore, by modifying or propagating a
443 covered work, you indicate your acceptance of this License to do so.
444
445 10. Automatic Licensing of Downstream Recipients.
446
447 Each time you convey a covered work, the recipient automatically
448 receives a license from the original licensors, to run, modify and
449 propagate that work, subject to this License. You are not responsible
450 for enforcing compliance by third parties with this License.
451
452 An "entity transaction" is a transaction transferring control of an
453 organization, or substantially all assets of one, or subdividing an
454 organization, or merging organizations. If propagation of a covered
455 work results from an entity transaction, each party to that
456 transaction who receives a copy of the work also receives whatever
457 licenses to the work the party's predecessor in interest had or could
458 give under the previous paragraph, plus a right to possession of the
459 Corresponding Source of the work from the predecessor in interest, if
460 the predecessor has it or can get it with reasonable efforts.
461
462 You may not impose any further restrictions on the exercise of the
463 rights granted or affirmed under this License. For example, you may
464 not impose a license fee, royalty, or other charge for exercise of
465 rights granted under this License, and you may not initiate litigation
466 (including a cross-claim or counterclaim in a lawsuit) alleging that
467 any patent claim is infringed by making, using, selling, offering for
468 sale, or importing the Program or any portion of it.
469
470 11. Patents.
471
472 A "contributor" is a copyright holder who authorizes use under this
473 License of the Program or a work on which the Program is based. The
474 work thus licensed is called the contributor's "contributor version".
475
476 A contributor's "essential patent claims" are all patent claims
477 owned or controlled by the contributor, whether already acquired or
478 hereafter acquired, that would be infringed by some manner, permitted
479 by this License, of making, using, or selling its contributor version,
480 but do not include claims that would be infringed only as a
481 consequence of further modification of the contributor version. For
482 purposes of this definition, "control" includes the right to grant
483 patent sublicenses in a manner consistent with the requirements of
484 this License.
485
486 Each contributor grants you a non-exclusive, worldwide, royalty-free
487 patent license under the contributor's essential patent claims, to
488 make, use, sell, offer for sale, import and otherwise run, modify and
489 propagate the contents of its contributor version.
490
491 In the following three paragraphs, a "patent license" is any express
492 agreement or commitment, however denominated, not to enforce a patent
493 (such as an express permission to practice a patent or covenant not to
494 sue for patent infringement). To "grant" such a patent license to a
495 party means to make such an agreement or commitment not to enforce a
496 patent against the party.
497
498 If you convey a covered work, knowingly relying on a patent license,
499 and the Corresponding Source of the work is not available for anyone
500 to copy, free of charge and under the terms of this License, through a
501 publicly available network server or other readily accessible means,
502 then you must either (1) cause the Corresponding Source to be so
503 available, or (2) arrange to deprive yourself of the benefit of the
504 patent license for this particular work, or (3) arrange, in a manner
505 consistent with the requirements of this License, to extend the patent
506 license to downstream recipients. "Knowingly relying" means you have
507 actual knowledge that, but for the patent license, your conveying the
508 covered work in a country, or your recipient's use of the covered work
509 in a country, would infringe one or more identifiable patents in that
510 country that you have reason to believe are valid.
511
512 If, pursuant to or in connection with a single transaction or
513 arrangement, you convey, or propagate by procuring conveyance of, a
514 covered work, and grant a patent license to some of the parties
515 receiving the covered work authorizing them to use, propagate, modify
516 or convey a specific copy of the covered work, then the patent license
517 you grant is automatically extended to all recipients of the covered
518 work and works based on it.
519
520 A patent license is "discriminatory" if it does not include within
521 the scope of its coverage, prohibits the exercise of, or is
522 conditioned on the non-exercise of one or more of the rights that are
523 specifically granted under this License. You may not convey a covered
524 work if you are a party to an arrangement with a third party that is
525 in the business of distributing software, under which you make payment
526 to the third party based on the extent of your activity of conveying
527 the work, and under which the third party grants, to any of the
528 parties who would receive the covered work from you, a discriminatory
529 patent license (a) in connection with copies of the covered work
530 conveyed by you (or copies made from those copies), or (b) primarily
531 for and in connection with specific products or compilations that
532 contain the covered work, unless you entered into that arrangement,
533 or that patent license was granted, prior to 28 March 2007.
534
535 Nothing in this License shall be construed as excluding or limiting
536 any implied license or other defenses to infringement that may
537 otherwise be available to you under applicable patent law.
538
539 12. No Surrender of Others' Freedom.
540
541 If conditions are imposed on you (whether by court order, agreement or
542 otherwise) that contradict the conditions of this License, they do not
543 excuse you from the conditions of this License. If you cannot convey a
544 covered work so as to satisfy simultaneously your obligations under this
545 License and any other pertinent obligations, then as a consequence you may
546 not convey it at all. For example, if you agree to terms that obligate you
547 to collect a royalty for further conveying from those to whom you convey
548 the Program, the only way you could satisfy both those terms and this
549 License would be to refrain entirely from conveying the Program.
550
551 13. Use with the GNU Affero General Public License.
552
553 Notwithstanding any other provision of this License, you have
554 permission to link or combine any covered work with a work licensed
555 under version 3 of the GNU Affero General Public License into a single
556 combined work, and to convey the resulting work. The terms of this
557 License will continue to apply to the part which is the covered work,
558 but the special requirements of the GNU Affero General Public License,
559 section 13, concerning interaction through a network will apply to the
560 combination as such.
561
562 14. Revised Versions of this License.
563
564 The Free Software Foundation may publish revised and/or new versions of
565 the GNU General Public License from time to time. Such new versions will
566 be similar in spirit to the present version, but may differ in detail to
567 address new problems or concerns.
568
569 Each version is given a distinguishing version number. If the
570 Program specifies that a certain numbered version of the GNU General
571 Public License "or any later version" applies to it, you have the
572 option of following the terms and conditions either of that numbered
573 version or of any later version published by the Free Software
574 Foundation. If the Program does not specify a version number of the
575 GNU General Public License, you may choose any version ever published
576 by the Free Software Foundation.
577
578 If the Program specifies that a proxy can decide which future
579 versions of the GNU General Public License can be used, that proxy's
580 public statement of acceptance of a version permanently authorizes you
581 to choose that version for the Program.
582
583 Later license versions may give you additional or different
584 permissions. However, no additional obligations are imposed on any
585 author or copyright holder as a result of your choosing to follow a
586 later version.
587
588 15. Disclaimer of Warranty.
589
590 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
591 APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
592 HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
593 OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
594 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
595 PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
596 IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
597 ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
598
599 16. Limitation of Liability.
600
601 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
602 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
603 THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
604 GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
605 USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
606 DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
607 PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
608 EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
609 SUCH DAMAGES.
610
611 17. Interpretation of Sections 15 and 16.
612
613 If the disclaimer of warranty and limitation of liability provided
614 above cannot be given local legal effect according to their terms,
615 reviewing courts shall apply local law that most closely approximates
616 an absolute waiver of all civil liability in connection with the
617 Program, unless a warranty or assumption of liability accompanies a
618 copy of the Program in return for a fee.
619
620 END OF TERMS AND CONDITIONS
621
622 How to Apply These Terms to Your New Programs
623
624 If you develop a new program, and you want it to be of the greatest
625 possible use to the public, the best way to achieve this is to make it
626 free software which everyone can redistribute and change under these terms.
627
628 To do so, attach the following notices to the program. It is safest
629 to attach them to the start of each source file to most effectively
630 state the exclusion of warranty; and each file should have at least
631 the "copyright" line and a pointer to where the full notice is found.
632
633 <one line to give the program's name and a brief idea of what it does.>
634 Copyright (C) <year> <name of author>
635
636 This program is free software: you can redistribute it and/or modify
637 it under the terms of the GNU General Public License as published by
638 the Free Software Foundation, either version 3 of the License, or
639 (at your option) any later version.
640
641 This program is distributed in the hope that it will be useful,
642 but WITHOUT ANY WARRANTY; without even the implied warranty of
643 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
644 GNU General Public License for more details.
645
646 You should have received a copy of the GNU General Public License
647 along with this program. If not, see <http://www.gnu.org/licenses/>.
648
649 Also add information on how to contact you by electronic and paper mail.
650
651 If the program does terminal interaction, make it output a short
652 notice like this when it starts in an interactive mode:
653
654 <program> Copyright (C) <year> <name of author>
655 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
656 This is free software, and you are welcome to redistribute it
657 under certain conditions; type `show c' for details.
658
659 The hypothetical commands `show w' and `show c' should show the appropriate
660 parts of the General Public License. Of course, your program's commands
661 might be different; for a GUI interface, you would use an "about box".
662
663 You should also get your employer (if you work as a programmer) or school,
664 if any, to sign a "copyright disclaimer" for the program, if necessary.
665 For more information on this, and how to apply and follow the GNU GPL, see
666 <http://www.gnu.org/licenses/>.
667
668 The GNU General Public License does not permit incorporating your program
669 into proprietary programs. If your program is a subroutine library, you
670 may consider it more useful to permit linking proprietary applications with
671 the library. If this is what you want to do, use the GNU Lesser General
672 Public License instead of this License. But first, please read
673 <http://www.gnu.org/philosophy/why-not-lgpl.html>.
0 Copyright (c) 2007-2011 The Beanstalkd Authors.
1
2 Permission is hereby granted, free of charge, to any person obtaining a copy of
3 this software and associated documentation files (the "Software"), to deal in
4 the Software without restriction, including without limitation the rights to
5 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
6 of the Software, and to permit persons to whom the Software is furnished to do
7 so, subject to the following conditions:
8
9 The above copyright notice and this permission notice shall be included in all
10 copies or substantial portions of the Software.
11
12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 SOFTWARE.
0 include mk/inc
1
2 VERS=$(shell mk/vers.sh)
3 TARG=beanstalkd
4 MOFILE=main.o
5 OFILES=\
6 conn.o\
7 file.o\
8 heap.o\
9 job.o\
10 ms.o\
11 net.o\
12 port-$(OS).o\
13 primes.o\
14 prot.o\
15 sd-daemon.o\
16 sock-$(OS).o\
17 srv.o\
18 time.o\
19 tube.o\
20 util.o\
21 vers.o\
22 walg.o\
23
24 TOFILES=\
25 heap-test.o\
26 integ-test.o\
27 job-test.o\
28 util-test.o\
29
30 HFILES=\
31 dat.h\
32 sd-daemon.h\
33
34 CLEANFILES=\
35 vers.c\
36 $(TARG)-*.tar.gz\
37
38 include mk/cmd
39 include mk/tst
40
41 vers.c:
42 mk/verc.sh >vers.c
43 ifneq ($(shell mk/verc.sh),$(shell cat vers.c 2>/dev/null))
44 .PHONY: vers.c
45 endif
46
47 dist: $(TARG)-$(VERS).tar.gz
48 .PHONY: dist
49
50 $(TARG)-$(VERS).tar:
51 git archive -o $@ --prefix=$(TARG)-$(VERS)/ v$(VERS)
52 mkdir -p $(TARG)-$(VERS)/mk
53 echo 'printf "$(VERS)"' >$(TARG)-$(VERS)/mk/vers.sh
54 chmod +x $(TARG)-$(VERS)/mk/vers.sh
55 tar --append -f $@ $(TARG)-$(VERS)/mk/vers.sh
56 sed 's/@VERSION@/$(VERS)/' <pkg/beanstalkd.spec.in >$(TARG)-$(VERS)/beanstalkd.spec
57 tar --append -f $@ $(TARG)-$(VERS)/beanstalkd.spec
58 cp NEWS.md $(TARG)-$(VERS)/NEWS.md
59 tar --append -f $@ $(TARG)-$(VERS)/NEWS.md
60 rm -r $(TARG)-$(VERS)
61
62 $(TARG)-$(VERS).tar.gz: $(TARG)-$(VERS).tar
63 gzip -f $<
+0
-77
Makefile.am less more
0 AUTOMAKE_OPTIONS = foreign no-dependencies subdir-objects
1 ACLOCAL_AMFLAGS = -I m4
2
3 program = beanstalkd
4
5 bin_PROGRAMS = $(program)
6 aux_sources = \
7 binlog.c \
8 conn.c \
9 job.c \
10 ms.c \
11 net.c \
12 port.c \
13 pq.c \
14 primes.c \
15 prot.c \
16 tube.c \
17 util.c
18 beanstalkd_SOURCES = beanstalkd.c $(aux_sources)
19
20 EXTRA_PROGRAMS = cutgen
21 cutgen_SOURCES = cutgen.c
22
23 tests = \
24 tests/test_job.c \
25 tests/test_pq.c
26
27 scripts = \
28 scripts/beanstalkd.init \
29 scripts/beanstalkd.sysconfig
30
31 readme = \
32 README-DEVELOPERS \
33 README-TESTS
34
35 EXTRA_DIST = cut.c $(tests) $(scripts) $(readme) cut.h sh-tests check.sh check-one.sh \
36 beanstalkd.spec.in \
37 binlog.h \
38 conn.h \
39 job.h \
40 ms.h \
41 net.h \
42 port.h \
43 pq.h \
44 primes.h \
45 prot.h \
46 stat.h \
47 tube.h \
48 util.h
49
50 dist_doc_DATA = doc/protocol.txt NEWS.md
51 dist_man_MANS = doc/beanstalkd.1
52
53 check-cut: tests/cutcheck
54 tests/cutcheck
55
56 check-shell: $(program)
57 SRCDIR=$(srcdir) $(srcdir)/check.sh $(srcdir)/sh-tests/*.{commands,sh}
58
59 check: check-cut check-shell
60
61 tests/cutcheck.c: $(tests) cutgen
62 mkdir -p tests
63 ./cutgen -o tests/cutcheck.c $(tests:%=$(srcdir)/%)
64
65 tests/cutcheck: tests/cutcheck.o cut.o $(aux_sources:.c=.o) $(tests:.c=.o)
66 $(LINK) $^ $(beanstalkd_LDADD) $(LIBS)
67
68 CLEANFILES = cutgen tests/cutcheck* tests/*.o
69
70 DISTCLEANFILES = core core.* gmon.out $(program)-*.tar.gz
71
72 dist-hook:
73 echo -e '#!/bin/sh\n\n# This file was generated by "make dist".\necho $(VERSION)' > $(distdir)/version.sh
74 chmod +x $(distdir)/version.sh
75 sed -e 's/\@VERSION\@/$(VERSION)/' $(srcdir)/beanstalkd.spec.in > $(distdir)/beanstalkd.spec
76
+0
-785
Makefile.in less more
0 # Makefile.in generated by automake 1.11.1 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
4 # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
5 # Inc.
6 # This Makefile.in is free software; the Free Software Foundation
7 # gives unlimited permission to copy and/or distribute it,
8 # with or without modifications, as long as this notice is preserved.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
12 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 # PARTICULAR PURPOSE.
14
15 @SET_MAKE@
16
17
18 VPATH = @srcdir@
19 pkgdatadir = $(datadir)/@PACKAGE@
20 pkgincludedir = $(includedir)/@PACKAGE@
21 pkglibdir = $(libdir)/@PACKAGE@
22 pkglibexecdir = $(libexecdir)/@PACKAGE@
23 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24 install_sh_DATA = $(install_sh) -c -m 644
25 install_sh_PROGRAM = $(install_sh) -c
26 install_sh_SCRIPT = $(install_sh) -c
27 INSTALL_HEADER = $(INSTALL_DATA)
28 transform = $(program_transform_name)
29 NORMAL_INSTALL = :
30 PRE_INSTALL = :
31 POST_INSTALL = :
32 NORMAL_UNINSTALL = :
33 PRE_UNINSTALL = :
34 POST_UNINSTALL = :
35 bin_PROGRAMS = $(am__EXEEXT_1)
36 EXTRA_PROGRAMS = cutgen$(EXEEXT)
37 subdir = .
38 DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \
39 $(dist_man_MANS) $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
40 $(srcdir)/config.h.in $(top_srcdir)/configure COPYING TODO \
41 install-sh missing
42 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
43 am__aclocal_m4_deps = $(top_srcdir)/m4/as-compiler-flag.m4 \
44 $(top_srcdir)/configure.in
45 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
46 $(ACLOCAL_M4)
47 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
48 configure.lineno config.status.lineno
49 mkinstalldirs = $(install_sh) -d
50 CONFIG_HEADER = config.h
51 CONFIG_CLEAN_FILES =
52 CONFIG_CLEAN_VPATH_FILES =
53 am__EXEEXT_1 = beanstalkd$(EXEEXT)
54 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \
55 "$(DESTDIR)$(docdir)"
56 PROGRAMS = $(bin_PROGRAMS)
57 am__objects_1 = binlog.$(OBJEXT) conn.$(OBJEXT) job.$(OBJEXT) \
58 ms.$(OBJEXT) net.$(OBJEXT) port.$(OBJEXT) pq.$(OBJEXT) \
59 primes.$(OBJEXT) prot.$(OBJEXT) tube.$(OBJEXT) util.$(OBJEXT)
60 am_beanstalkd_OBJECTS = beanstalkd.$(OBJEXT) $(am__objects_1)
61 beanstalkd_OBJECTS = $(am_beanstalkd_OBJECTS)
62 beanstalkd_LDADD = $(LDADD)
63 am_cutgen_OBJECTS = cutgen.$(OBJEXT)
64 cutgen_OBJECTS = $(am_cutgen_OBJECTS)
65 cutgen_LDADD = $(LDADD)
66 DEFAULT_INCLUDES = -I.@am__isrc@
67 depcomp =
68 am__depfiles_maybe =
69 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
70 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
71 CCLD = $(CC)
72 LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
73 SOURCES = $(beanstalkd_SOURCES) $(cutgen_SOURCES)
74 DIST_SOURCES = $(beanstalkd_SOURCES) $(cutgen_SOURCES)
75 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
76 am__vpath_adj = case $$p in \
77 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
78 *) f=$$p;; \
79 esac;
80 am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
81 am__install_max = 40
82 am__nobase_strip_setup = \
83 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
84 am__nobase_strip = \
85 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
86 am__nobase_list = $(am__nobase_strip_setup); \
87 for p in $$list; do echo "$$p $$p"; done | \
88 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
89 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
90 if (++n[$$2] == $(am__install_max)) \
91 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
92 END { for (dir in files) print dir, files[dir] }'
93 am__base_list = \
94 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
95 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
96 man1dir = $(mandir)/man1
97 NROFF = nroff
98 MANS = $(dist_man_MANS)
99 DATA = $(dist_doc_DATA)
100 ETAGS = etags
101 CTAGS = ctags
102 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
103 distdir = $(PACKAGE)-$(VERSION)
104 top_distdir = $(distdir)
105 am__remove_distdir = \
106 { test ! -d "$(distdir)" \
107 || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
108 && rm -fr "$(distdir)"; }; }
109 DIST_ARCHIVES = $(distdir).tar.gz
110 GZIP_ENV = --best
111 distuninstallcheck_listfiles = find . -type f -print
112 distcleancheck_listfiles = find . -type f -print
113 ACLOCAL = @ACLOCAL@
114 AMTAR = @AMTAR@
115 AUTOCONF = @AUTOCONF@
116 AUTOHEADER = @AUTOHEADER@
117 AUTOMAKE = @AUTOMAKE@
118 AWK = @AWK@
119 CC = @CC@
120 CCDEPMODE = @CCDEPMODE@
121 CFLAGS = @CFLAGS@
122 CPP = @CPP@
123 CPPFLAGS = @CPPFLAGS@
124 CYGPATH_W = @CYGPATH_W@
125 DEFS = @DEFS@
126 DEPDIR = @DEPDIR@
127 ECHO_C = @ECHO_C@
128 ECHO_N = @ECHO_N@
129 ECHO_T = @ECHO_T@
130 EGREP = @EGREP@
131 EXEEXT = @EXEEXT@
132 GREP = @GREP@
133 INSTALL = @INSTALL@
134 INSTALL_DATA = @INSTALL_DATA@
135 INSTALL_PROGRAM = @INSTALL_PROGRAM@
136 INSTALL_SCRIPT = @INSTALL_SCRIPT@
137 INSTALL_STRIP_FLAG = @INSTALL_STRIP_FLAG@
138 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
139 LDFLAGS = @LDFLAGS@
140 LIBOBJS = @LIBOBJS@
141 LIBS = @LIBS@
142 LTLIBOBJS = @LTLIBOBJS@
143 MAINT = @MAINT@
144 MAKEINFO = @MAKEINFO@
145 MKDIR_P = @MKDIR_P@
146 OBJEXT = @OBJEXT@
147 PACKAGE = @PACKAGE@
148 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
149 PACKAGE_NAME = @PACKAGE_NAME@
150 PACKAGE_STRING = @PACKAGE_STRING@
151 PACKAGE_TARNAME = @PACKAGE_TARNAME@
152 PACKAGE_URL = @PACKAGE_URL@
153 PACKAGE_VERSION = @PACKAGE_VERSION@
154 PATH_SEPARATOR = @PATH_SEPARATOR@
155 SET_MAKE = @SET_MAKE@
156 SHELL = @SHELL@
157 STRIP = @STRIP@
158 VERSION = @VERSION@
159 abs_builddir = @abs_builddir@
160 abs_srcdir = @abs_srcdir@
161 abs_top_builddir = @abs_top_builddir@
162 abs_top_srcdir = @abs_top_srcdir@
163 ac_ct_CC = @ac_ct_CC@
164 am__include = @am__include@
165 am__leading_dot = @am__leading_dot@
166 am__quote = @am__quote@
167 am__tar = @am__tar@
168 am__untar = @am__untar@
169 bindir = @bindir@
170 build_alias = @build_alias@
171 builddir = @builddir@
172 datadir = @datadir@
173 datarootdir = @datarootdir@
174 docdir = @docdir@
175 dvidir = @dvidir@
176 exec_prefix = @exec_prefix@
177 host_alias = @host_alias@
178 htmldir = @htmldir@
179 includedir = @includedir@
180 infodir = @infodir@
181 install_sh = @install_sh@
182 libdir = @libdir@
183 libexecdir = @libexecdir@
184 localedir = @localedir@
185 localstatedir = @localstatedir@
186 mandir = @mandir@
187 mkdir_p = @mkdir_p@
188 oldincludedir = @oldincludedir@
189 pdfdir = @pdfdir@
190 prefix = @prefix@
191 program_transform_name = @program_transform_name@
192 psdir = @psdir@
193 sbindir = @sbindir@
194 sharedstatedir = @sharedstatedir@
195 srcdir = @srcdir@
196 sysconfdir = @sysconfdir@
197 target_alias = @target_alias@
198 top_build_prefix = @top_build_prefix@
199 top_builddir = @top_builddir@
200 top_srcdir = @top_srcdir@
201 AUTOMAKE_OPTIONS = foreign no-dependencies subdir-objects
202 ACLOCAL_AMFLAGS = -I m4
203 program = beanstalkd
204 aux_sources = \
205 binlog.c \
206 conn.c \
207 job.c \
208 ms.c \
209 net.c \
210 port.c \
211 pq.c \
212 primes.c \
213 prot.c \
214 tube.c \
215 util.c
216
217 beanstalkd_SOURCES = beanstalkd.c $(aux_sources)
218 cutgen_SOURCES = cutgen.c
219 tests = \
220 tests/test_job.c \
221 tests/test_pq.c
222
223 scripts = \
224 scripts/beanstalkd.init \
225 scripts/beanstalkd.sysconfig
226
227 readme = \
228 README-DEVELOPERS \
229 README-TESTS
230
231 EXTRA_DIST = cut.c $(tests) $(scripts) $(readme) cut.h sh-tests check.sh check-one.sh \
232 beanstalkd.spec.in \
233 binlog.h \
234 conn.h \
235 job.h \
236 ms.h \
237 net.h \
238 port.h \
239 pq.h \
240 primes.h \
241 prot.h \
242 stat.h \
243 tube.h \
244 util.h
245
246 dist_doc_DATA = doc/protocol.txt NEWS.md
247 dist_man_MANS = doc/beanstalkd.1
248 CLEANFILES = cutgen tests/cutcheck* tests/*.o
249 DISTCLEANFILES = core core.* gmon.out $(program)-*.tar.gz
250 all: config.h
251 $(MAKE) $(AM_MAKEFLAGS) all-am
252
253 .SUFFIXES:
254 .SUFFIXES: .c .o .obj
255 am--refresh:
256 @:
257 $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
258 @for dep in $?; do \
259 case '$(am__configure_deps)' in \
260 *$$dep*) \
261 echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
262 $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
263 && exit 0; \
264 exit 1;; \
265 esac; \
266 done; \
267 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
268 $(am__cd) $(top_srcdir) && \
269 $(AUTOMAKE) --foreign Makefile
270 .PRECIOUS: Makefile
271 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
272 @case '$?' in \
273 *config.status*) \
274 echo ' $(SHELL) ./config.status'; \
275 $(SHELL) ./config.status;; \
276 *) \
277 echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
278 cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
279 esac;
280
281 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
282 $(SHELL) ./config.status --recheck
283
284 $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
285 $(am__cd) $(srcdir) && $(AUTOCONF)
286 $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
287 $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
288 $(am__aclocal_m4_deps):
289
290 config.h: stamp-h1
291 @if test ! -f $@; then \
292 rm -f stamp-h1; \
293 $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
294 else :; fi
295
296 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
297 @rm -f stamp-h1
298 cd $(top_builddir) && $(SHELL) ./config.status config.h
299 $(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
300 ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
301 rm -f stamp-h1
302 touch $@
303
304 distclean-hdr:
305 -rm -f config.h stamp-h1
306 install-binPROGRAMS: $(bin_PROGRAMS)
307 @$(NORMAL_INSTALL)
308 test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
309 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
310 for p in $$list; do echo "$$p $$p"; done | \
311 sed 's/$(EXEEXT)$$//' | \
312 while read p p1; do if test -f $$p; \
313 then echo "$$p"; echo "$$p"; else :; fi; \
314 done | \
315 sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
316 -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
317 sed 'N;N;N;s,\n, ,g' | \
318 $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
319 { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
320 if ($$2 == $$4) files[d] = files[d] " " $$1; \
321 else { print "f", $$3 "/" $$4, $$1; } } \
322 END { for (d in files) print "f", d, files[d] }' | \
323 while read type dir files; do \
324 if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
325 test -z "$$files" || { \
326 echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
327 $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
328 } \
329 ; done
330
331 uninstall-binPROGRAMS:
332 @$(NORMAL_UNINSTALL)
333 @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
334 files=`for p in $$list; do echo "$$p"; done | \
335 sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
336 -e 's/$$/$(EXEEXT)/' `; \
337 test -n "$$list" || exit 0; \
338 echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
339 cd "$(DESTDIR)$(bindir)" && rm -f $$files
340
341 clean-binPROGRAMS:
342 -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
343 beanstalkd$(EXEEXT): $(beanstalkd_OBJECTS) $(beanstalkd_DEPENDENCIES)
344 @rm -f beanstalkd$(EXEEXT)
345 $(LINK) $(beanstalkd_OBJECTS) $(beanstalkd_LDADD) $(LIBS)
346 cutgen$(EXEEXT): $(cutgen_OBJECTS) $(cutgen_DEPENDENCIES)
347 @rm -f cutgen$(EXEEXT)
348 $(LINK) $(cutgen_OBJECTS) $(cutgen_LDADD) $(LIBS)
349
350 mostlyclean-compile:
351 -rm -f *.$(OBJEXT)
352
353 distclean-compile:
354 -rm -f *.tab.c
355
356 .c.o:
357 $(COMPILE) -c -o $@ $<
358
359 .c.obj:
360 $(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
361 install-man1: $(dist_man_MANS)
362 @$(NORMAL_INSTALL)
363 test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
364 @list=''; test -n "$(man1dir)" || exit 0; \
365 { for i in $$list; do echo "$$i"; done; \
366 l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
367 sed -n '/\.1[a-z]*$$/p'; \
368 } | while read p; do \
369 if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
370 echo "$$d$$p"; echo "$$p"; \
371 done | \
372 sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
373 -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
374 sed 'N;N;s,\n, ,g' | { \
375 list=; while read file base inst; do \
376 if test "$$base" = "$$inst"; then list="$$list $$file"; else \
377 echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
378 $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
379 fi; \
380 done; \
381 for i in $$list; do echo "$$i"; done | $(am__base_list) | \
382 while read files; do \
383 test -z "$$files" || { \
384 echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
385 $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
386 done; }
387
388 uninstall-man1:
389 @$(NORMAL_UNINSTALL)
390 @list=''; test -n "$(man1dir)" || exit 0; \
391 files=`{ for i in $$list; do echo "$$i"; done; \
392 l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
393 sed -n '/\.1[a-z]*$$/p'; \
394 } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
395 -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
396 test -z "$$files" || { \
397 echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
398 cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
399 install-dist_docDATA: $(dist_doc_DATA)
400 @$(NORMAL_INSTALL)
401 test -z "$(docdir)" || $(MKDIR_P) "$(DESTDIR)$(docdir)"
402 @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
403 for p in $$list; do \
404 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
405 echo "$$d$$p"; \
406 done | $(am__base_list) | \
407 while read files; do \
408 echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \
409 $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \
410 done
411
412 uninstall-dist_docDATA:
413 @$(NORMAL_UNINSTALL)
414 @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
415 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
416 test -n "$$files" || exit 0; \
417 echo " ( cd '$(DESTDIR)$(docdir)' && rm -f" $$files ")"; \
418 cd "$(DESTDIR)$(docdir)" && rm -f $$files
419
420 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
421 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
422 unique=`for i in $$list; do \
423 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
424 done | \
425 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
426 END { if (nonempty) { for (i in files) print i; }; }'`; \
427 mkid -fID $$unique
428 tags: TAGS
429
430 TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
431 $(TAGS_FILES) $(LISP)
432 set x; \
433 here=`pwd`; \
434 list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
435 unique=`for i in $$list; do \
436 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
437 done | \
438 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
439 END { if (nonempty) { for (i in files) print i; }; }'`; \
440 shift; \
441 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
442 test -n "$$unique" || unique=$$empty_fix; \
443 if test $$# -gt 0; then \
444 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
445 "$$@" $$unique; \
446 else \
447 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
448 $$unique; \
449 fi; \
450 fi
451 ctags: CTAGS
452 CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
453 $(TAGS_FILES) $(LISP)
454 list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
455 unique=`for i in $$list; do \
456 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
457 done | \
458 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
459 END { if (nonempty) { for (i in files) print i; }; }'`; \
460 test -z "$(CTAGS_ARGS)$$unique" \
461 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
462 $$unique
463
464 GTAGS:
465 here=`$(am__cd) $(top_builddir) && pwd` \
466 && $(am__cd) $(top_srcdir) \
467 && gtags -i $(GTAGS_ARGS) "$$here"
468
469 distclean-tags:
470 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
471
472 distdir: $(DISTFILES)
473 @list='$(MANS)'; if test -n "$$list"; then \
474 list=`for p in $$list; do \
475 if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
476 if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
477 if test -n "$$list" && \
478 grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
479 echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
480 grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \
481 echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \
482 echo " typically \`make maintainer-clean' will remove them" >&2; \
483 exit 1; \
484 else :; fi; \
485 else :; fi
486 $(am__remove_distdir)
487 test -d "$(distdir)" || mkdir "$(distdir)"
488 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
489 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
490 list='$(DISTFILES)'; \
491 dist_files=`for file in $$list; do echo $$file; done | \
492 sed -e "s|^$$srcdirstrip/||;t" \
493 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
494 case $$dist_files in \
495 */*) $(MKDIR_P) `echo "$$dist_files" | \
496 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
497 sort -u` ;; \
498 esac; \
499 for file in $$dist_files; do \
500 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
501 if test -d $$d/$$file; then \
502 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
503 if test -d "$(distdir)/$$file"; then \
504 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
505 fi; \
506 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
507 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
508 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
509 fi; \
510 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
511 else \
512 test -f "$(distdir)/$$file" \
513 || cp -p $$d/$$file "$(distdir)/$$file" \
514 || exit 1; \
515 fi; \
516 done
517 $(MAKE) $(AM_MAKEFLAGS) \
518 top_distdir="$(top_distdir)" distdir="$(distdir)" \
519 dist-hook
520 -test -n "$(am__skip_mode_fix)" \
521 || find "$(distdir)" -type d ! -perm -755 \
522 -exec chmod u+rwx,go+rx {} \; -o \
523 ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
524 ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
525 ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
526 || chmod -R a+r "$(distdir)"
527 dist-gzip: distdir
528 tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
529 $(am__remove_distdir)
530
531 dist-bzip2: distdir
532 tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
533 $(am__remove_distdir)
534
535 dist-lzma: distdir
536 tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
537 $(am__remove_distdir)
538
539 dist-xz: distdir
540 tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
541 $(am__remove_distdir)
542
543 dist-tarZ: distdir
544 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
545 $(am__remove_distdir)
546
547 dist-shar: distdir
548 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
549 $(am__remove_distdir)
550
551 dist-zip: distdir
552 -rm -f $(distdir).zip
553 zip -rq $(distdir).zip $(distdir)
554 $(am__remove_distdir)
555
556 dist dist-all: distdir
557 tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
558 $(am__remove_distdir)
559
560 # This target untars the dist file and tries a VPATH configuration. Then
561 # it guarantees that the distribution is self-contained by making another
562 # tarfile.
563 distcheck: dist
564 case '$(DIST_ARCHIVES)' in \
565 *.tar.gz*) \
566 GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
567 *.tar.bz2*) \
568 bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
569 *.tar.lzma*) \
570 lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
571 *.tar.xz*) \
572 xz -dc $(distdir).tar.xz | $(am__untar) ;;\
573 *.tar.Z*) \
574 uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
575 *.shar.gz*) \
576 GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
577 *.zip*) \
578 unzip $(distdir).zip ;;\
579 esac
580 chmod -R a-w $(distdir); chmod a+w $(distdir)
581 mkdir $(distdir)/_build
582 mkdir $(distdir)/_inst
583 chmod a-w $(distdir)
584 test -d $(distdir)/_build || exit 0; \
585 dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
586 && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
587 && am__cwd=`pwd` \
588 && $(am__cd) $(distdir)/_build \
589 && ../configure --srcdir=.. --prefix="$$dc_install_base" \
590 $(DISTCHECK_CONFIGURE_FLAGS) \
591 && $(MAKE) $(AM_MAKEFLAGS) \
592 && $(MAKE) $(AM_MAKEFLAGS) dvi \
593 && $(MAKE) $(AM_MAKEFLAGS) check \
594 && $(MAKE) $(AM_MAKEFLAGS) install \
595 && $(MAKE) $(AM_MAKEFLAGS) installcheck \
596 && $(MAKE) $(AM_MAKEFLAGS) uninstall \
597 && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
598 distuninstallcheck \
599 && chmod -R a-w "$$dc_install_base" \
600 && ({ \
601 (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
602 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
603 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
604 && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
605 distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
606 } || { rm -rf "$$dc_destdir"; exit 1; }) \
607 && rm -rf "$$dc_destdir" \
608 && $(MAKE) $(AM_MAKEFLAGS) dist \
609 && rm -rf $(DIST_ARCHIVES) \
610 && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
611 && cd "$$am__cwd" \
612 || exit 1
613 $(am__remove_distdir)
614 @(echo "$(distdir) archives ready for distribution: "; \
615 list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
616 sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
617 distuninstallcheck:
618 @$(am__cd) '$(distuninstallcheck_dir)' \
619 && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
620 || { echo "ERROR: files left after uninstall:" ; \
621 if test -n "$(DESTDIR)"; then \
622 echo " (check DESTDIR support)"; \
623 fi ; \
624 $(distuninstallcheck_listfiles) ; \
625 exit 1; } >&2
626 distcleancheck: distclean
627 @if test '$(srcdir)' = . ; then \
628 echo "ERROR: distcleancheck can only run from a VPATH build" ; \
629 exit 1 ; \
630 fi
631 @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
632 || { echo "ERROR: files left in build directory after distclean:" ; \
633 $(distcleancheck_listfiles) ; \
634 exit 1; } >&2
635 check-am: all-am
636 check: check-am
637 all-am: Makefile $(PROGRAMS) $(MANS) $(DATA) config.h
638 installdirs:
639 for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(docdir)"; do \
640 test -z "$$dir" || $(MKDIR_P) "$$dir"; \
641 done
642 install: install-am
643 install-exec: install-exec-am
644 install-data: install-data-am
645 uninstall: uninstall-am
646
647 install-am: all-am
648 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
649
650 installcheck: installcheck-am
651 install-strip:
652 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
653 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
654 `test -z '$(STRIP)' || \
655 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
656 mostlyclean-generic:
657
658 clean-generic:
659 -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
660
661 distclean-generic:
662 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
663 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
664 -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
665
666 maintainer-clean-generic:
667 @echo "This command is intended for maintainers to use"
668 @echo "it deletes files that may require special tools to rebuild."
669 clean: clean-am
670
671 clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
672
673 distclean: distclean-am
674 -rm -f $(am__CONFIG_DISTCLEAN_FILES)
675 -rm -f Makefile
676 distclean-am: clean-am distclean-compile distclean-generic \
677 distclean-hdr distclean-tags
678
679 dvi: dvi-am
680
681 dvi-am:
682
683 html: html-am
684
685 html-am:
686
687 info: info-am
688
689 info-am:
690
691 install-data-am: install-dist_docDATA install-man
692
693 install-dvi: install-dvi-am
694
695 install-dvi-am:
696
697 install-exec-am: install-binPROGRAMS
698
699 install-html: install-html-am
700
701 install-html-am:
702
703 install-info: install-info-am
704
705 install-info-am:
706
707 install-man: install-man1
708
709 install-pdf: install-pdf-am
710
711 install-pdf-am:
712
713 install-ps: install-ps-am
714
715 install-ps-am:
716
717 installcheck-am:
718
719 maintainer-clean: maintainer-clean-am
720 -rm -f $(am__CONFIG_DISTCLEAN_FILES)
721 -rm -rf $(top_srcdir)/autom4te.cache
722 -rm -f Makefile
723 maintainer-clean-am: distclean-am maintainer-clean-generic
724
725 mostlyclean: mostlyclean-am
726
727 mostlyclean-am: mostlyclean-compile mostlyclean-generic
728
729 pdf: pdf-am
730
731 pdf-am:
732
733 ps: ps-am
734
735 ps-am:
736
737 uninstall-am: uninstall-binPROGRAMS uninstall-dist_docDATA \
738 uninstall-man
739
740 uninstall-man: uninstall-man1
741
742 .MAKE: all install-am install-strip
743
744 .PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
745 clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \
746 dist-gzip dist-hook dist-lzma dist-shar dist-tarZ dist-xz \
747 dist-zip distcheck distclean distclean-compile \
748 distclean-generic distclean-hdr distclean-tags distcleancheck \
749 distdir distuninstallcheck dvi dvi-am html html-am info \
750 info-am install install-am install-binPROGRAMS install-data \
751 install-data-am install-dist_docDATA install-dvi \
752 install-dvi-am install-exec install-exec-am install-html \
753 install-html-am install-info install-info-am install-man \
754 install-man1 install-pdf install-pdf-am install-ps \
755 install-ps-am install-strip installcheck installcheck-am \
756 installdirs maintainer-clean maintainer-clean-generic \
757 mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
758 ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \
759 uninstall-dist_docDATA uninstall-man uninstall-man1
760
761
762 check-cut: tests/cutcheck
763 tests/cutcheck
764
765 check-shell: $(program)
766 SRCDIR=$(srcdir) $(srcdir)/check.sh $(srcdir)/sh-tests/*.{commands,sh}
767
768 check: check-cut check-shell
769
770 tests/cutcheck.c: $(tests) cutgen
771 mkdir -p tests
772 ./cutgen -o tests/cutcheck.c $(tests:%=$(srcdir)/%)
773
774 tests/cutcheck: tests/cutcheck.o cut.o $(aux_sources:.c=.o) $(tests:.c=.o)
775 $(LINK) $^ $(beanstalkd_LDADD) $(LIBS)
776
777 dist-hook:
778 echo -e '#!/bin/sh\n\n# This file was generated by "make dist".\necho $(VERSION)' > $(distdir)/version.sh
779 chmod +x $(distdir)/version.sh
780 sed -e 's/\@VERSION\@/$(VERSION)/' $(srcdir)/beanstalkd.spec.in > $(distdir)/beanstalkd.spec
781
782 # Tell versions [3.59,3.63) of GNU make to not export all variables.
783 # Otherwise a system limit (for SysV at least) may be exceeded.
784 .NOEXPORT:
0 What's New
1 ----------
0 # Highlights
21
3 * The put command now discards the entire job body before returning
4 JOB_TOO_BIG. Previously, it interpreted the job body as commands. This was a
5 potential security hole, where malicious users could craft job payload data
6 to inject commands without cooperation from the beanstalk client
7 application.
8 * Fix issue #40 by requiring an absolute path when `-b` is used with `-d`.
2 - removed dependency on libevent
3 - no more autotools; to build beanstalkd, just type "make"
4 - incremental binlog compaction; fixes #43
5 - removed flag -d; alternatives are in the "adm" directory
6
7 # More News
8
9 - switch to MIT license
10 - remove DEBUG compile flag
11 - more interesting make examples in README
12 - change default CFLAGS
13 - verbose mode; closes #52
14 - properly timeout reserve-with-timeout; fixes #78
15 - document that EPOLLRDHUP was introduced in Linux 2.6.17.
16 - read beanstalkd 1.4.6's log format for compatibility
17 - report size of attempted read for WAL read errors
18 - accurately report position of WAL file errors
19 - add file index to job stats
20 - clarify behavior of cumulative stats; closes #81
21 - adding support for counting deletes on a tube
22 - delete command now deletes delayed jobs
23 - fix segfault; closes #71
24 - bsd build fix; PATH_MAX is defined in limits.h
25 - bsd build fix; echo -n is not portable
26 - do not read in STATE_WAIT; fixes #22
27 - document the new binlog stats
28 - redo the WAL code, improving style
29 - more careful binlog read checking
30 - in log recovery, recompute delay with current time; fixes #62
31 - provide and document more system admin tools
32 - support systemd socket activation
933
1034 Full list of changes in this release (includes authorship information):
11 <http://github.com/kr/beanstalkd/compare/v1.4.5...v1.4.6>
12
35 <http://github.com/kr/beanstalkd/compare/v1.4.6...v1.5>
00 This is beanstalkd, a fast, general-purpose work queue.
1 See http://kr.github.com/beanstalkd/ for general info.
12
2 See http://xph.us/software/beanstalkd/ for general info.
3 QUICK START
34
4 To build beanstalkd, type "./configure" then "make". (You might need to type
5 "gmake"; our build requires GNU make.)
5 $ make
6 $ ./beanstalkd
67
7 Requires libevent 1.4.1 or later. You can find libevent at
8 http://www.monkey.org/~provos/libevent/.
8 also,
99
10 To install, copy the file "beanstalkd" anywhere you like.
10 $ make CFLAGS=-g
11 $ make CC=clang
12 $ make check
13 $ make install
14 $ make install PREFIX=/usr
15
16 You might need to type "gmake"; our build requires GNU make.
17 Requires Linux (2.6.17 or later), Mac OS X, or FreeBSD.
18 See doc/protocol.txt for details of the network protocol.
19
20
21 SUBDIRECTORIES
22
23 adm files useful for system administrators
24 ct testing tool; see https://github.com/kr/ct
25 doc documentation
26 mk include files for make
27 pkg miscelaneous files for packagers
28 sh-tests tests written as shell scripts
29
30
31 TESTS
32
33 There are two kinds of tests here: unit tests and shell tests.
34
35 == Unit Tests ==
36
37 Test functions are in *-test.c.
38
39 == Shell Tests ==
40
41 Shell tests go in the sh-tests directory and are to be written in pairs:
42
43 my_test.commands
44 my_test.expected
45
46 Each .commands file will be nc'd to beanstalkd, and the response diff'd
47 with the appropriate .expected file. If the response is not identical to the
48 .expected file, the test fails. At the moment, the test harness bails upon the
49 first failure, but it could easily be extended to finish the tests and print
50 full results.
51
52 IMPORTANT: Since beanstalkd expects \r\n line endings, you must be sure to
53 include those in your files. You can tell vim to do this with
54 :set ff=dos
55
56 Copyright 2007-2011 the authors of beanstalkd.
57 Copyright in contributions to beanstalkd is retained
58 by the original copyright holder of each contribution.
59 See the COPYING file for terms of use.
+0
-12
README-DEVELOPERS less more
0 See doc/protocol.txt for details of the on-the-wire protocol.
1
2 Ensure you have autoconf, automake, and libtool installed.
3
4 The first time you build beanstalkd, you must first run "./autogen.sh".
5
6 Then, do the common "./configure" followed by "make".
7
8 To run unit tests, type "make check".
9
10 These unit tests use a slightly modified bundled version of CUT, originally
11 from http://sourceforge.net/projects/cut/.
+0
-25
README-TESTS less more
0 = Testing Beanstalkd =
1
2 There are two kinds of tests here: unit tests and shell tests.
3
4 == Unit Tests ==
5
6 These go in tests/test_*.c. See the CUT documentation for more info.
7
8 http://sourceforge.net/projects/cut/
9
10 == Shell Tests ==
11
12 Shell tests go in the sh-tests directory and are to be written in pairs:
13 -my_test.commands
14 -my_test.expected
15
16 Each .commands file will be nc'd to beanstalkd, and the response diff'd
17 with the appropriate .expected file. If the response is not identical to the
18 .expected file, the test fails. At the moment, the test harness bails upon the
19 first failure, but it could easily be extended to finish the tests and print
20 full results.
21
22 IMPORTANT: Since beanstalkd expects \r\n line endings, you must be sure to
23 include those in your files. You can tell vim to do this with
24 :set ff=dos
+0
-9
TODO less more
0 Protocol
1 --------
2 Replication
3 Peek random job
4
5 Server
6 ------
7 Runtime verbosity switch
8 Speed profiling
+0
-992
aclocal.m4 less more
0 # generated automatically by aclocal 1.11.1 -*- Autoconf -*-
1
2 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3 # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
7
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 # PARTICULAR PURPOSE.
12
13 m4_ifndef([AC_AUTOCONF_VERSION],
14 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
15 m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
16 [m4_warning([this file was generated for autoconf 2.65.
17 You have another version of autoconf. It may work, but is not guaranteed to.
18 If you have problems, you may need to regenerate the build system entirely.
19 To do so, use the procedure documented by the package, typically `autoreconf'.])])
20
21 # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
22 #
23 # This file is free software; the Free Software Foundation
24 # gives unlimited permission to copy and/or distribute it,
25 # with or without modifications, as long as this notice is preserved.
26
27 # AM_AUTOMAKE_VERSION(VERSION)
28 # ----------------------------
29 # Automake X.Y traces this macro to ensure aclocal.m4 has been
30 # generated from the m4 files accompanying Automake X.Y.
31 # (This private macro should not be called outside this file.)
32 AC_DEFUN([AM_AUTOMAKE_VERSION],
33 [am__api_version='1.11'
34 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
35 dnl require some minimum version. Point them to the right macro.
36 m4_if([$1], [1.11.1], [],
37 [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
38 ])
39
40 # _AM_AUTOCONF_VERSION(VERSION)
41 # -----------------------------
42 # aclocal traces this macro to find the Autoconf version.
43 # This is a private macro too. Using m4_define simplifies
44 # the logic in aclocal, which can simply ignore this definition.
45 m4_define([_AM_AUTOCONF_VERSION], [])
46
47 # AM_SET_CURRENT_AUTOMAKE_VERSION
48 # -------------------------------
49 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
50 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
51 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
52 [AM_AUTOMAKE_VERSION([1.11.1])dnl
53 m4_ifndef([AC_AUTOCONF_VERSION],
54 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
55 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
56
57 # AM_AUX_DIR_EXPAND -*- Autoconf -*-
58
59 # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
60 #
61 # This file is free software; the Free Software Foundation
62 # gives unlimited permission to copy and/or distribute it,
63 # with or without modifications, as long as this notice is preserved.
64
65 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
66 # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
67 # `$srcdir', `$srcdir/..', or `$srcdir/../..'.
68 #
69 # Of course, Automake must honor this variable whenever it calls a
70 # tool from the auxiliary directory. The problem is that $srcdir (and
71 # therefore $ac_aux_dir as well) can be either absolute or relative,
72 # depending on how configure is run. This is pretty annoying, since
73 # it makes $ac_aux_dir quite unusable in subdirectories: in the top
74 # source directory, any form will work fine, but in subdirectories a
75 # relative path needs to be adjusted first.
76 #
77 # $ac_aux_dir/missing
78 # fails when called from a subdirectory if $ac_aux_dir is relative
79 # $top_srcdir/$ac_aux_dir/missing
80 # fails if $ac_aux_dir is absolute,
81 # fails when called from a subdirectory in a VPATH build with
82 # a relative $ac_aux_dir
83 #
84 # The reason of the latter failure is that $top_srcdir and $ac_aux_dir
85 # are both prefixed by $srcdir. In an in-source build this is usually
86 # harmless because $srcdir is `.', but things will broke when you
87 # start a VPATH build or use an absolute $srcdir.
88 #
89 # So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
90 # iff we strip the leading $srcdir from $ac_aux_dir. That would be:
91 # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
92 # and then we would define $MISSING as
93 # MISSING="\${SHELL} $am_aux_dir/missing"
94 # This will work as long as MISSING is not called from configure, because
95 # unfortunately $(top_srcdir) has no meaning in configure.
96 # However there are other variables, like CC, which are often used in
97 # configure, and could therefore not use this "fixed" $ac_aux_dir.
98 #
99 # Another solution, used here, is to always expand $ac_aux_dir to an
100 # absolute PATH. The drawback is that using absolute paths prevent a
101 # configured tree to be moved without reconfiguration.
102
103 AC_DEFUN([AM_AUX_DIR_EXPAND],
104 [dnl Rely on autoconf to set up CDPATH properly.
105 AC_PREREQ([2.50])dnl
106 # expand $ac_aux_dir to an absolute path
107 am_aux_dir=`cd $ac_aux_dir && pwd`
108 ])
109
110 # AM_CONDITIONAL -*- Autoconf -*-
111
112 # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
113 # Free Software Foundation, Inc.
114 #
115 # This file is free software; the Free Software Foundation
116 # gives unlimited permission to copy and/or distribute it,
117 # with or without modifications, as long as this notice is preserved.
118
119 # serial 9
120
121 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
122 # -------------------------------------
123 # Define a conditional.
124 AC_DEFUN([AM_CONDITIONAL],
125 [AC_PREREQ(2.52)dnl
126 ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
127 [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
128 AC_SUBST([$1_TRUE])dnl
129 AC_SUBST([$1_FALSE])dnl
130 _AM_SUBST_NOTMAKE([$1_TRUE])dnl
131 _AM_SUBST_NOTMAKE([$1_FALSE])dnl
132 m4_define([_AM_COND_VALUE_$1], [$2])dnl
133 if $2; then
134 $1_TRUE=
135 $1_FALSE='#'
136 else
137 $1_TRUE='#'
138 $1_FALSE=
139 fi
140 AC_CONFIG_COMMANDS_PRE(
141 [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
142 AC_MSG_ERROR([[conditional "$1" was never defined.
143 Usually this means the macro was only invoked conditionally.]])
144 fi])])
145
146 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
147 # Free Software Foundation, Inc.
148 #
149 # This file is free software; the Free Software Foundation
150 # gives unlimited permission to copy and/or distribute it,
151 # with or without modifications, as long as this notice is preserved.
152
153 # serial 10
154
155 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
156 # written in clear, in which case automake, when reading aclocal.m4,
157 # will think it sees a *use*, and therefore will trigger all it's
158 # C support machinery. Also note that it means that autoscan, seeing
159 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
160
161
162 # _AM_DEPENDENCIES(NAME)
163 # ----------------------
164 # See how the compiler implements dependency checking.
165 # NAME is "CC", "CXX", "GCJ", or "OBJC".
166 # We try a few techniques and use that to set a single cache variable.
167 #
168 # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
169 # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
170 # dependency, and given that the user is not expected to run this macro,
171 # just rely on AC_PROG_CC.
172 AC_DEFUN([_AM_DEPENDENCIES],
173 [AC_REQUIRE([AM_SET_DEPDIR])dnl
174 AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
175 AC_REQUIRE([AM_MAKE_INCLUDE])dnl
176 AC_REQUIRE([AM_DEP_TRACK])dnl
177
178 ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
179 [$1], CXX, [depcc="$CXX" am_compiler_list=],
180 [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
181 [$1], UPC, [depcc="$UPC" am_compiler_list=],
182 [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
183 [depcc="$$1" am_compiler_list=])
184
185 AC_CACHE_CHECK([dependency style of $depcc],
186 [am_cv_$1_dependencies_compiler_type],
187 [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
188 # We make a subdir and do the tests there. Otherwise we can end up
189 # making bogus files that we don't know about and never remove. For
190 # instance it was reported that on HP-UX the gcc test will end up
191 # making a dummy file named `D' -- because `-MD' means `put the output
192 # in D'.
193 mkdir conftest.dir
194 # Copy depcomp to subdir because otherwise we won't find it if we're
195 # using a relative directory.
196 cp "$am_depcomp" conftest.dir
197 cd conftest.dir
198 # We will build objects and dependencies in a subdirectory because
199 # it helps to detect inapplicable dependency modes. For instance
200 # both Tru64's cc and ICC support -MD to output dependencies as a
201 # side effect of compilation, but ICC will put the dependencies in
202 # the current directory while Tru64 will put them in the object
203 # directory.
204 mkdir sub
205
206 am_cv_$1_dependencies_compiler_type=none
207 if test "$am_compiler_list" = ""; then
208 am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
209 fi
210 am__universal=false
211 m4_case([$1], [CC],
212 [case " $depcc " in #(
213 *\ -arch\ *\ -arch\ *) am__universal=true ;;
214 esac],
215 [CXX],
216 [case " $depcc " in #(
217 *\ -arch\ *\ -arch\ *) am__universal=true ;;
218 esac])
219
220 for depmode in $am_compiler_list; do
221 # Setup a source with many dependencies, because some compilers
222 # like to wrap large dependency lists on column 80 (with \), and
223 # we should not choose a depcomp mode which is confused by this.
224 #
225 # We need to recreate these files for each test, as the compiler may
226 # overwrite some of them when testing with obscure command lines.
227 # This happens at least with the AIX C compiler.
228 : > sub/conftest.c
229 for i in 1 2 3 4 5 6; do
230 echo '#include "conftst'$i'.h"' >> sub/conftest.c
231 # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
232 # Solaris 8's {/usr,}/bin/sh.
233 touch sub/conftst$i.h
234 done
235 echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
236
237 # We check with `-c' and `-o' for the sake of the "dashmstdout"
238 # mode. It turns out that the SunPro C++ compiler does not properly
239 # handle `-M -o', and we need to detect this. Also, some Intel
240 # versions had trouble with output in subdirs
241 am__obj=sub/conftest.${OBJEXT-o}
242 am__minus_obj="-o $am__obj"
243 case $depmode in
244 gcc)
245 # This depmode causes a compiler race in universal mode.
246 test "$am__universal" = false || continue
247 ;;
248 nosideeffect)
249 # after this tag, mechanisms are not by side-effect, so they'll
250 # only be used when explicitly requested
251 if test "x$enable_dependency_tracking" = xyes; then
252 continue
253 else
254 break
255 fi
256 ;;
257 msvisualcpp | msvcmsys)
258 # This compiler won't grok `-c -o', but also, the minuso test has
259 # not run yet. These depmodes are late enough in the game, and
260 # so weak that their functioning should not be impacted.
261 am__obj=conftest.${OBJEXT-o}
262 am__minus_obj=
263 ;;
264 none) break ;;
265 esac
266 if depmode=$depmode \
267 source=sub/conftest.c object=$am__obj \
268 depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
269 $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
270 >/dev/null 2>conftest.err &&
271 grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
272 grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
273 grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
274 ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
275 # icc doesn't choke on unknown options, it will just issue warnings
276 # or remarks (even with -Werror). So we grep stderr for any message
277 # that says an option was ignored or not supported.
278 # When given -MP, icc 7.0 and 7.1 complain thusly:
279 # icc: Command line warning: ignoring option '-M'; no argument required
280 # The diagnosis changed in icc 8.0:
281 # icc: Command line remark: option '-MP' not supported
282 if (grep 'ignoring option' conftest.err ||
283 grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
284 am_cv_$1_dependencies_compiler_type=$depmode
285 break
286 fi
287 fi
288 done
289
290 cd ..
291 rm -rf conftest.dir
292 else
293 am_cv_$1_dependencies_compiler_type=none
294 fi
295 ])
296 AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
297 AM_CONDITIONAL([am__fastdep$1], [
298 test "x$enable_dependency_tracking" != xno \
299 && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
300 ])
301
302
303 # AM_SET_DEPDIR
304 # -------------
305 # Choose a directory name for dependency files.
306 # This macro is AC_REQUIREd in _AM_DEPENDENCIES
307 AC_DEFUN([AM_SET_DEPDIR],
308 [AC_REQUIRE([AM_SET_LEADING_DOT])dnl
309 AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
310 ])
311
312
313 # AM_DEP_TRACK
314 # ------------
315 AC_DEFUN([AM_DEP_TRACK],
316 [AC_ARG_ENABLE(dependency-tracking,
317 [ --disable-dependency-tracking speeds up one-time build
318 --enable-dependency-tracking do not reject slow dependency extractors])
319 if test "x$enable_dependency_tracking" != xno; then
320 am_depcomp="$ac_aux_dir/depcomp"
321 AMDEPBACKSLASH='\'
322 fi
323 AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
324 AC_SUBST([AMDEPBACKSLASH])dnl
325 _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
326 ])
327
328 # Generate code to set up dependency tracking. -*- Autoconf -*-
329
330 # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
331 # Free Software Foundation, Inc.
332 #
333 # This file is free software; the Free Software Foundation
334 # gives unlimited permission to copy and/or distribute it,
335 # with or without modifications, as long as this notice is preserved.
336
337 #serial 5
338
339 # _AM_OUTPUT_DEPENDENCY_COMMANDS
340 # ------------------------------
341 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
342 [{
343 # Autoconf 2.62 quotes --file arguments for eval, but not when files
344 # are listed without --file. Let's play safe and only enable the eval
345 # if we detect the quoting.
346 case $CONFIG_FILES in
347 *\'*) eval set x "$CONFIG_FILES" ;;
348 *) set x $CONFIG_FILES ;;
349 esac
350 shift
351 for mf
352 do
353 # Strip MF so we end up with the name of the file.
354 mf=`echo "$mf" | sed -e 's/:.*$//'`
355 # Check whether this is an Automake generated Makefile or not.
356 # We used to match only the files named `Makefile.in', but
357 # some people rename them; so instead we look at the file content.
358 # Grep'ing the first line is not enough: some people post-process
359 # each Makefile.in and add a new line on top of each file to say so.
360 # Grep'ing the whole file is not good either: AIX grep has a line
361 # limit of 2048, but all sed's we know have understand at least 4000.
362 if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
363 dirpart=`AS_DIRNAME("$mf")`
364 else
365 continue
366 fi
367 # Extract the definition of DEPDIR, am__include, and am__quote
368 # from the Makefile without running `make'.
369 DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
370 test -z "$DEPDIR" && continue
371 am__include=`sed -n 's/^am__include = //p' < "$mf"`
372 test -z "am__include" && continue
373 am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
374 # When using ansi2knr, U may be empty or an underscore; expand it
375 U=`sed -n 's/^U = //p' < "$mf"`
376 # Find all dependency output files, they are included files with
377 # $(DEPDIR) in their names. We invoke sed twice because it is the
378 # simplest approach to changing $(DEPDIR) to its actual value in the
379 # expansion.
380 for file in `sed -n "
381 s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
382 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
383 # Make sure the directory exists.
384 test -f "$dirpart/$file" && continue
385 fdir=`AS_DIRNAME(["$file"])`
386 AS_MKDIR_P([$dirpart/$fdir])
387 # echo "creating $dirpart/$file"
388 echo '# dummy' > "$dirpart/$file"
389 done
390 done
391 }
392 ])# _AM_OUTPUT_DEPENDENCY_COMMANDS
393
394
395 # AM_OUTPUT_DEPENDENCY_COMMANDS
396 # -----------------------------
397 # This macro should only be invoked once -- use via AC_REQUIRE.
398 #
399 # This code is only required when automatic dependency tracking
400 # is enabled. FIXME. This creates each `.P' file that we will
401 # need in order to bootstrap the dependency handling code.
402 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
403 [AC_CONFIG_COMMANDS([depfiles],
404 [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
405 [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
406 ])
407
408 # Do all the work for Automake. -*- Autoconf -*-
409
410 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
411 # 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
412 #
413 # This file is free software; the Free Software Foundation
414 # gives unlimited permission to copy and/or distribute it,
415 # with or without modifications, as long as this notice is preserved.
416
417 # serial 16
418
419 # This macro actually does too much. Some checks are only needed if
420 # your package does certain things. But this isn't really a big deal.
421
422 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
423 # AM_INIT_AUTOMAKE([OPTIONS])
424 # -----------------------------------------------
425 # The call with PACKAGE and VERSION arguments is the old style
426 # call (pre autoconf-2.50), which is being phased out. PACKAGE
427 # and VERSION should now be passed to AC_INIT and removed from
428 # the call to AM_INIT_AUTOMAKE.
429 # We support both call styles for the transition. After
430 # the next Automake release, Autoconf can make the AC_INIT
431 # arguments mandatory, and then we can depend on a new Autoconf
432 # release and drop the old call support.
433 AC_DEFUN([AM_INIT_AUTOMAKE],
434 [AC_PREREQ([2.62])dnl
435 dnl Autoconf wants to disallow AM_ names. We explicitly allow
436 dnl the ones we care about.
437 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
438 AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
439 AC_REQUIRE([AC_PROG_INSTALL])dnl
440 if test "`cd $srcdir && pwd`" != "`pwd`"; then
441 # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
442 # is not polluted with repeated "-I."
443 AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
444 # test to see if srcdir already configured
445 if test -f $srcdir/config.status; then
446 AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
447 fi
448 fi
449
450 # test whether we have cygpath
451 if test -z "$CYGPATH_W"; then
452 if (cygpath --version) >/dev/null 2>/dev/null; then
453 CYGPATH_W='cygpath -w'
454 else
455 CYGPATH_W=echo
456 fi
457 fi
458 AC_SUBST([CYGPATH_W])
459
460 # Define the identity of the package.
461 dnl Distinguish between old-style and new-style calls.
462 m4_ifval([$2],
463 [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
464 AC_SUBST([PACKAGE], [$1])dnl
465 AC_SUBST([VERSION], [$2])],
466 [_AM_SET_OPTIONS([$1])dnl
467 dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
468 m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
469 [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
470 AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
471 AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
472
473 _AM_IF_OPTION([no-define],,
474 [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
475 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
476
477 # Some tools Automake needs.
478 AC_REQUIRE([AM_SANITY_CHECK])dnl
479 AC_REQUIRE([AC_ARG_PROGRAM])dnl
480 AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
481 AM_MISSING_PROG(AUTOCONF, autoconf)
482 AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
483 AM_MISSING_PROG(AUTOHEADER, autoheader)
484 AM_MISSING_PROG(MAKEINFO, makeinfo)
485 AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
486 AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
487 AC_REQUIRE([AM_PROG_MKDIR_P])dnl
488 # We need awk for the "check" target. The system "awk" is bad on
489 # some platforms.
490 AC_REQUIRE([AC_PROG_AWK])dnl
491 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
492 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
493 _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
494 [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
495 [_AM_PROG_TAR([v7])])])
496 _AM_IF_OPTION([no-dependencies],,
497 [AC_PROVIDE_IFELSE([AC_PROG_CC],
498 [_AM_DEPENDENCIES(CC)],
499 [define([AC_PROG_CC],
500 defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
501 AC_PROVIDE_IFELSE([AC_PROG_CXX],
502 [_AM_DEPENDENCIES(CXX)],
503 [define([AC_PROG_CXX],
504 defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
505 AC_PROVIDE_IFELSE([AC_PROG_OBJC],
506 [_AM_DEPENDENCIES(OBJC)],
507 [define([AC_PROG_OBJC],
508 defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
509 ])
510 _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
511 dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
512 dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro
513 dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
514 AC_CONFIG_COMMANDS_PRE(dnl
515 [m4_provide_if([_AM_COMPILER_EXEEXT],
516 [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
517 ])
518
519 dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
520 dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
521 dnl mangled by Autoconf and run in a shell conditional statement.
522 m4_define([_AC_COMPILER_EXEEXT],
523 m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
524
525
526 # When config.status generates a header, we must update the stamp-h file.
527 # This file resides in the same directory as the config header
528 # that is generated. The stamp files are numbered to have different names.
529
530 # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
531 # loop where config.status creates the headers, so we can generate
532 # our stamp files there.
533 AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
534 [# Compute $1's index in $config_headers.
535 _am_arg=$1
536 _am_stamp_count=1
537 for _am_header in $config_headers :; do
538 case $_am_header in
539 $_am_arg | $_am_arg:* )
540 break ;;
541 * )
542 _am_stamp_count=`expr $_am_stamp_count + 1` ;;
543 esac
544 done
545 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
546
547 # Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc.
548 #
549 # This file is free software; the Free Software Foundation
550 # gives unlimited permission to copy and/or distribute it,
551 # with or without modifications, as long as this notice is preserved.
552
553 # AM_PROG_INSTALL_SH
554 # ------------------
555 # Define $install_sh.
556 AC_DEFUN([AM_PROG_INSTALL_SH],
557 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
558 if test x"${install_sh}" != xset; then
559 case $am_aux_dir in
560 *\ * | *\ *)
561 install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
562 *)
563 install_sh="\${SHELL} $am_aux_dir/install-sh"
564 esac
565 fi
566 AC_SUBST(install_sh)])
567
568 # Copyright (C) 2003, 2005 Free Software Foundation, Inc.
569 #
570 # This file is free software; the Free Software Foundation
571 # gives unlimited permission to copy and/or distribute it,
572 # with or without modifications, as long as this notice is preserved.
573
574 # serial 2
575
576 # Check whether the underlying file-system supports filenames
577 # with a leading dot. For instance MS-DOS doesn't.
578 AC_DEFUN([AM_SET_LEADING_DOT],
579 [rm -rf .tst 2>/dev/null
580 mkdir .tst 2>/dev/null
581 if test -d .tst; then
582 am__leading_dot=.
583 else
584 am__leading_dot=_
585 fi
586 rmdir .tst 2>/dev/null
587 AC_SUBST([am__leading_dot])])
588
589 # Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
590 # From Jim Meyering
591
592 # Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008
593 # Free Software Foundation, Inc.
594 #
595 # This file is free software; the Free Software Foundation
596 # gives unlimited permission to copy and/or distribute it,
597 # with or without modifications, as long as this notice is preserved.
598
599 # serial 5
600
601 # AM_MAINTAINER_MODE([DEFAULT-MODE])
602 # ----------------------------------
603 # Control maintainer-specific portions of Makefiles.
604 # Default is to disable them, unless `enable' is passed literally.
605 # For symmetry, `disable' may be passed as well. Anyway, the user
606 # can override the default with the --enable/--disable switch.
607 AC_DEFUN([AM_MAINTAINER_MODE],
608 [m4_case(m4_default([$1], [disable]),
609 [enable], [m4_define([am_maintainer_other], [disable])],
610 [disable], [m4_define([am_maintainer_other], [enable])],
611 [m4_define([am_maintainer_other], [enable])
612 m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])])
613 AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles])
614 dnl maintainer-mode's default is 'disable' unless 'enable' is passed
615 AC_ARG_ENABLE([maintainer-mode],
616 [ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful
617 (and sometimes confusing) to the casual installer],
618 [USE_MAINTAINER_MODE=$enableval],
619 [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes]))
620 AC_MSG_RESULT([$USE_MAINTAINER_MODE])
621 AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes])
622 MAINT=$MAINTAINER_MODE_TRUE
623 AC_SUBST([MAINT])dnl
624 ]
625 )
626
627 AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
628
629 # Check to see how 'make' treats includes. -*- Autoconf -*-
630
631 # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc.
632 #
633 # This file is free software; the Free Software Foundation
634 # gives unlimited permission to copy and/or distribute it,
635 # with or without modifications, as long as this notice is preserved.
636
637 # serial 4
638
639 # AM_MAKE_INCLUDE()
640 # -----------------
641 # Check to see how make treats includes.
642 AC_DEFUN([AM_MAKE_INCLUDE],
643 [am_make=${MAKE-make}
644 cat > confinc << 'END'
645 am__doit:
646 @echo this is the am__doit target
647 .PHONY: am__doit
648 END
649 # If we don't find an include directive, just comment out the code.
650 AC_MSG_CHECKING([for style of include used by $am_make])
651 am__include="#"
652 am__quote=
653 _am_result=none
654 # First try GNU make style include.
655 echo "include confinc" > confmf
656 # Ignore all kinds of additional output from `make'.
657 case `$am_make -s -f confmf 2> /dev/null` in #(
658 *the\ am__doit\ target*)
659 am__include=include
660 am__quote=
661 _am_result=GNU
662 ;;
663 esac
664 # Now try BSD make style include.
665 if test "$am__include" = "#"; then
666 echo '.include "confinc"' > confmf
667 case `$am_make -s -f confmf 2> /dev/null` in #(
668 *the\ am__doit\ target*)
669 am__include=.include
670 am__quote="\""
671 _am_result=BSD
672 ;;
673 esac
674 fi
675 AC_SUBST([am__include])
676 AC_SUBST([am__quote])
677 AC_MSG_RESULT([$_am_result])
678 rm -f confinc confmf
679 ])
680
681 # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
682
683 # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
684 # Free Software Foundation, Inc.
685 #
686 # This file is free software; the Free Software Foundation
687 # gives unlimited permission to copy and/or distribute it,
688 # with or without modifications, as long as this notice is preserved.
689
690 # serial 6
691
692 # AM_MISSING_PROG(NAME, PROGRAM)
693 # ------------------------------
694 AC_DEFUN([AM_MISSING_PROG],
695 [AC_REQUIRE([AM_MISSING_HAS_RUN])
696 $1=${$1-"${am_missing_run}$2"}
697 AC_SUBST($1)])
698
699
700 # AM_MISSING_HAS_RUN
701 # ------------------
702 # Define MISSING if not defined so far and test if it supports --run.
703 # If it does, set am_missing_run to use it, otherwise, to nothing.
704 AC_DEFUN([AM_MISSING_HAS_RUN],
705 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
706 AC_REQUIRE_AUX_FILE([missing])dnl
707 if test x"${MISSING+set}" != xset; then
708 case $am_aux_dir in
709 *\ * | *\ *)
710 MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
711 *)
712 MISSING="\${SHELL} $am_aux_dir/missing" ;;
713 esac
714 fi
715 # Use eval to expand $SHELL
716 if eval "$MISSING --run true"; then
717 am_missing_run="$MISSING --run "
718 else
719 am_missing_run=
720 AC_MSG_WARN([`missing' script is too old or missing])
721 fi
722 ])
723
724 # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
725 #
726 # This file is free software; the Free Software Foundation
727 # gives unlimited permission to copy and/or distribute it,
728 # with or without modifications, as long as this notice is preserved.
729
730 # AM_PROG_MKDIR_P
731 # ---------------
732 # Check for `mkdir -p'.
733 AC_DEFUN([AM_PROG_MKDIR_P],
734 [AC_PREREQ([2.60])dnl
735 AC_REQUIRE([AC_PROG_MKDIR_P])dnl
736 dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P,
737 dnl while keeping a definition of mkdir_p for backward compatibility.
738 dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
739 dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
740 dnl Makefile.ins that do not define MKDIR_P, so we do our own
741 dnl adjustment using top_builddir (which is defined more often than
742 dnl MKDIR_P).
743 AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
744 case $mkdir_p in
745 [[\\/$]]* | ?:[[\\/]]*) ;;
746 */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
747 esac
748 ])
749
750 # Helper functions for option handling. -*- Autoconf -*-
751
752 # Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc.
753 #
754 # This file is free software; the Free Software Foundation
755 # gives unlimited permission to copy and/or distribute it,
756 # with or without modifications, as long as this notice is preserved.
757
758 # serial 4
759
760 # _AM_MANGLE_OPTION(NAME)
761 # -----------------------
762 AC_DEFUN([_AM_MANGLE_OPTION],
763 [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
764
765 # _AM_SET_OPTION(NAME)
766 # ------------------------------
767 # Set option NAME. Presently that only means defining a flag for this option.
768 AC_DEFUN([_AM_SET_OPTION],
769 [m4_define(_AM_MANGLE_OPTION([$1]), 1)])
770
771 # _AM_SET_OPTIONS(OPTIONS)
772 # ----------------------------------
773 # OPTIONS is a space-separated list of Automake options.
774 AC_DEFUN([_AM_SET_OPTIONS],
775 [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
776
777 # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
778 # -------------------------------------------
779 # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
780 AC_DEFUN([_AM_IF_OPTION],
781 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
782
783 # Check to make sure that the build environment is sane. -*- Autoconf -*-
784
785 # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
786 # Free Software Foundation, Inc.
787 #
788 # This file is free software; the Free Software Foundation
789 # gives unlimited permission to copy and/or distribute it,
790 # with or without modifications, as long as this notice is preserved.
791
792 # serial 5
793
794 # AM_SANITY_CHECK
795 # ---------------
796 AC_DEFUN([AM_SANITY_CHECK],
797 [AC_MSG_CHECKING([whether build environment is sane])
798 # Just in case
799 sleep 1
800 echo timestamp > conftest.file
801 # Reject unsafe characters in $srcdir or the absolute working directory
802 # name. Accept space and tab only in the latter.
803 am_lf='
804 '
805 case `pwd` in
806 *[[\\\"\#\$\&\'\`$am_lf]]*)
807 AC_MSG_ERROR([unsafe absolute working directory name]);;
808 esac
809 case $srcdir in
810 *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
811 AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
812 esac
813
814 # Do `set' in a subshell so we don't clobber the current shell's
815 # arguments. Must try -L first in case configure is actually a
816 # symlink; some systems play weird games with the mod time of symlinks
817 # (eg FreeBSD returns the mod time of the symlink's containing
818 # directory).
819 if (
820 set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
821 if test "$[*]" = "X"; then
822 # -L didn't work.
823 set X `ls -t "$srcdir/configure" conftest.file`
824 fi
825 rm -f conftest.file
826 if test "$[*]" != "X $srcdir/configure conftest.file" \
827 && test "$[*]" != "X conftest.file $srcdir/configure"; then
828
829 # If neither matched, then we have a broken ls. This can happen
830 # if, for instance, CONFIG_SHELL is bash and it inherits a
831 # broken ls alias from the environment. This has actually
832 # happened. Such a system could not be considered "sane".
833 AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
834 alias in your environment])
835 fi
836
837 test "$[2]" = conftest.file
838 )
839 then
840 # Ok.
841 :
842 else
843 AC_MSG_ERROR([newly created file is older than distributed files!
844 Check your system clock])
845 fi
846 AC_MSG_RESULT(yes)])
847
848 # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
849 #
850 # This file is free software; the Free Software Foundation
851 # gives unlimited permission to copy and/or distribute it,
852 # with or without modifications, as long as this notice is preserved.
853
854 # AM_PROG_INSTALL_STRIP
855 # ---------------------
856 # One issue with vendor `install' (even GNU) is that you can't
857 # specify the program used to strip binaries. This is especially
858 # annoying in cross-compiling environments, where the build's strip
859 # is unlikely to handle the host's binaries.
860 # Fortunately install-sh will honor a STRIPPROG variable, so we
861 # always use install-sh in `make install-strip', and initialize
862 # STRIPPROG with the value of the STRIP variable (set by the user).
863 AC_DEFUN([AM_PROG_INSTALL_STRIP],
864 [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
865 # Installed binaries are usually stripped using `strip' when the user
866 # run `make install-strip'. However `strip' might not be the right
867 # tool to use in cross-compilation environments, therefore Automake
868 # will honor the `STRIP' environment variable to overrule this program.
869 dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
870 if test "$cross_compiling" != no; then
871 AC_CHECK_TOOL([STRIP], [strip], :)
872 fi
873 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
874 AC_SUBST([INSTALL_STRIP_PROGRAM])])
875
876 # Copyright (C) 2006, 2008 Free Software Foundation, Inc.
877 #
878 # This file is free software; the Free Software Foundation
879 # gives unlimited permission to copy and/or distribute it,
880 # with or without modifications, as long as this notice is preserved.
881
882 # serial 2
883
884 # _AM_SUBST_NOTMAKE(VARIABLE)
885 # ---------------------------
886 # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
887 # This macro is traced by Automake.
888 AC_DEFUN([_AM_SUBST_NOTMAKE])
889
890 # AM_SUBST_NOTMAKE(VARIABLE)
891 # ---------------------------
892 # Public sister of _AM_SUBST_NOTMAKE.
893 AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
894
895 # Check how to create a tarball. -*- Autoconf -*-
896
897 # Copyright (C) 2004, 2005 Free Software Foundation, Inc.
898 #
899 # This file is free software; the Free Software Foundation
900 # gives unlimited permission to copy and/or distribute it,
901 # with or without modifications, as long as this notice is preserved.
902
903 # serial 2
904
905 # _AM_PROG_TAR(FORMAT)
906 # --------------------
907 # Check how to create a tarball in format FORMAT.
908 # FORMAT should be one of `v7', `ustar', or `pax'.
909 #
910 # Substitute a variable $(am__tar) that is a command
911 # writing to stdout a FORMAT-tarball containing the directory
912 # $tardir.
913 # tardir=directory && $(am__tar) > result.tar
914 #
915 # Substitute a variable $(am__untar) that extract such
916 # a tarball read from stdin.
917 # $(am__untar) < result.tar
918 AC_DEFUN([_AM_PROG_TAR],
919 [# Always define AMTAR for backward compatibility.
920 AM_MISSING_PROG([AMTAR], [tar])
921 m4_if([$1], [v7],
922 [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
923 [m4_case([$1], [ustar],, [pax],,
924 [m4_fatal([Unknown tar format])])
925 AC_MSG_CHECKING([how to create a $1 tar archive])
926 # Loop over all known methods to create a tar archive until one works.
927 _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
928 _am_tools=${am_cv_prog_tar_$1-$_am_tools}
929 # Do not fold the above two line into one, because Tru64 sh and
930 # Solaris sh will not grok spaces in the rhs of `-'.
931 for _am_tool in $_am_tools
932 do
933 case $_am_tool in
934 gnutar)
935 for _am_tar in tar gnutar gtar;
936 do
937 AM_RUN_LOG([$_am_tar --version]) && break
938 done
939 am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
940 am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
941 am__untar="$_am_tar -xf -"
942 ;;
943 plaintar)
944 # Must skip GNU tar: if it does not support --format= it doesn't create
945 # ustar tarball either.
946 (tar --version) >/dev/null 2>&1 && continue
947 am__tar='tar chf - "$$tardir"'
948 am__tar_='tar chf - "$tardir"'
949 am__untar='tar xf -'
950 ;;
951 pax)
952 am__tar='pax -L -x $1 -w "$$tardir"'
953 am__tar_='pax -L -x $1 -w "$tardir"'
954 am__untar='pax -r'
955 ;;
956 cpio)
957 am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
958 am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
959 am__untar='cpio -i -H $1 -d'
960 ;;
961 none)
962 am__tar=false
963 am__tar_=false
964 am__untar=false
965 ;;
966 esac
967
968 # If the value was cached, stop now. We just wanted to have am__tar
969 # and am__untar set.
970 test -n "${am_cv_prog_tar_$1}" && break
971
972 # tar/untar a dummy directory, and stop if the command works
973 rm -rf conftest.dir
974 mkdir conftest.dir
975 echo GrepMe > conftest.dir/file
976 AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
977 rm -rf conftest.dir
978 if test -s conftest.tar; then
979 AM_RUN_LOG([$am__untar <conftest.tar])
980 grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
981 fi
982 done
983 rm -rf conftest.dir
984
985 AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
986 AC_MSG_RESULT([$am_cv_prog_tar_$1])])
987 AC_SUBST([am__tar])
988 AC_SUBST([am__untar])
989 ]) # _AM_PROG_TAR
990
991 m4_include([m4/as-compiler-flag.m4])
0 The usual way to run beanstalkd is to type its name
1 in a Unix shell prompt, like this:
2
3 $ beanstalkd
4
5 This will start up the process and give you control over it.
6 You can control its output (by default output is printed to
7 the screen; you can arrange to have output go into file
8 b.log by typing ">b.log" at the end of the command line),
9 pause and restart the process (by pressing Control-Z and
10 typing "fg"), and kill it (by pressing Control-C).
11 This is most convenient while writing programs that use
12 beanstalkd (or when working on beanstalkd itself), since
13 you might want to start and stop it many times and regularly
14 inspect its output.
15
16 If you want beanstalkd to start when your operating system
17 boots, the mechanism varies.
18
19 Traditionally, you must add a command line to the shell script
20 in /etc/rc (which is read by init when the system boots),
21 using the "&" notation to run beanstalkd in the background.
22 This would suffice for most situations, but it isn't always
23 possible.
24
25 These days, many popular operating systems have a replacement
26 init program with its own configuration language. Example
27 configuration files for several of these are included in
28 subdirectories here, but the most common is probably "System V
29 init", which reads /etc/inittab for lines describing commands
30 to run at various times. If this file exists, you can add
31 a line something like
32
33 bean:345:respawn:su nobody -c 'exec /usr/bin/beanstalkd'
34
35 and type "telinit q" to tell init to reread its configuration.
36 Type "man 5 inittab" for details of this notation.
0 <?xml version="1.0" encoding="UTF-8"?>
1 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
2 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 <plist version="1.0">
4 <dict>
5 <key>Label</key>
6 <string>beanstalkd</string>
7
8 <key>UserName</key>
9 <string>nobody</string>
10
11 <key>ProgramArguments</key>
12 <array>
13 <string>/usr/local/bin/beanstalkd</string>
14 </array>
15
16 <key>KeepAlive</key>
17 <true/>
18 </dict>
19 </plist>
0 [Unit]
1 Description=Beanstalkd is a simple, fast work queue
2
3 [Service]
4 User=nobody
5 ExecStart=/usr/bin/beanstalkd
0 [Unit]
1 Description=Socket for beanstalkd, a simple, fast work queue
2
3 [Socket]
4 ListenStream=11300
5
6 [Install]
7 WantedBy=sockets.target
0 #!/bin/sh
1 #
2 # beanstalkd - a simple, fast workqueue service
3 #
4 # chkconfig: - 57 47
5 # description: a simple, fast workqueue service
6 # processname: beanstalkd
7 # config: /etc/sysconfig/beanstalkd
8 #
9
10 ### BEGIN INIT INFO
11 # Provides: beanstalkd
12 # Required-Start: $local_fs $network $remote_fs
13 # Required-Stop: $local_fs $network $remote_fs
14 # Short-Description: start and stop beanstalkd
15 # Description: a simple, fast workqueue service
16 ### END INIT INFO
17
18 # Source function library.
19 . /etc/rc.d/init.d/functions
20
21 # Source networking configuration.
22 . /etc/sysconfig/network
23
24 # Check that networking is up.
25 [ "$NETWORKING" = "no" ] && exit
26 exec="/usr/bin/beanstalkd"
27 prog=$(basename $exec)
28
29 # default options, overruled by items in sysconfig
30 BEANSTALKD_ADDR=0.0.0.0
31 BEANSTALKD_PORT=11300
32 BEANSTALKD_USER=beanstalkd
33
34 [ -e /etc/sysconfig/beanstalkd ] && . /etc/sysconfig/beanstalkd
35
36 lockfile=/var/lock/subsys/beanstalkd
37
38 start() {
39 [ -x $exec ] || exit 5
40 echo -n $"Starting $prog: "
41 # if not running, start it up here, usually something like "daemon $exec"
42 options="-l ${BEANSTALKD_ADDR} -p ${BEANSTALKD_PORT} -u ${BEANSTALKD_USER}"
43 if [ "${BEANSTALKD_MAX_JOB_SIZE}" != "" ]; then
44 options="${options} -z ${BEANSTALKD_MAX_JOB_SIZE}"
45 fi
46
47 if [ "${BEANSTALKD_BINLOG_DIR}" != "" ]; then
48 if [ ! -d "${BEANSTALKD_BINLOG_DIR}" ]; then
49 echo "Creating binlog directory (${BEANSTALKD_BINLOG_DIR})"
50 mkdir -p ${BEANSTALKD_BINLOG_DIR} && chown ${BEANSTALKD_USER}:${BEANSTALKD_USER} ${BEANSTALKD_BINLOG_DIR}
51 fi
52 options="${options} -b ${BEANSTALKD_BINLOG_DIR}"
53 if [ "${BEANSTALKD_BINLOG_FSYNC_PERIOD}" != "" ]; then
54 options="${options} -f ${BEANSTALKD_BINLOG_FSYNC_PERIOD}"
55 else
56 options="${options} -F"
57 fi
58 if [ "${BEANSTALKD_BINLOG_SIZE}" != "" ]; then
59 options="${options} -s ${BEANSTALKD_BINLOG_SIZE}"
60 fi
61 fi
62
63 daemon $exec -d $options
64 retval=$?
65 echo
66 [ $retval -eq 0 ] && touch $lockfile
67 return $retval
68 }
69
70 stop() {
71 echo -n $"Stopping $prog: "
72 # stop it here, often "killproc $prog"
73 killproc $prog -INT
74 retval=$?
75 echo
76 [ $retval -eq 0 ] && rm -f $lockfile
77 return $retval
78 }
79
80 restart() {
81 stop
82 start
83 }
84
85 reload() {
86 restart
87 }
88
89 force_reload() {
90 restart
91 }
92
93 rh_status() {
94 # run checks to determine if the service is running or use generic status
95 status $prog
96 }
97
98 rh_status_q() {
99 rh_status >/dev/null 2>&1
100 }
101
102
103 case "$1" in
104 start)
105 rh_status_q && exit 0
106 $1
107 ;;
108 stop)
109 rh_status_q || exit 0
110 $1
111 ;;
112 restart)
113 $1
114 ;;
115 reload)
116 rh_status_q || exit 7
117 $1
118 ;;
119 force-reload)
120 force_reload
121 ;;
122 status)
123 rh_status
124 ;;
125 condrestart|try-restart)
126 rh_status_q || exit 0
127 restart
128 ;;
129 *)
130 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
131 exit 2
132 esac
133 exit $?
134
0 # System configuration for the beanstalkd daemon
1
2 # Available options correspond to the options to the
3 # beanstalkd commandline.
4
5 BEANSTALKD_ADDR=0.0.0.0
6 BEANSTALKD_PORT=11300
7 BEANSTALKD_USER=beanstalkd
8
9 # Job size is left to the default. Uncomment and set it
10 # to a value to have it take affect.
11 #BEANSTALKD_MAX_JOB_SIZE=65535
12
13 # Using the binlog is off by default.
14 #
15 # The direcory to house the binlog. This will be created
16 # if it does not exist
17 #BEANSTALKD_BINLOG_DIR=/var/lib/beanstalkd/binlog
18 #
19 # fsync the binlog at most once every N milliseconds.
20 # setting this to 0 means 'always fsync'. If this is unset,
21 # and the binlog is used, then no explicit fsync is ever
22 # performed. That is, the -F option is used.
23 #BEANSTALKD_BINLOG_FSYNC_PERIOD=
24 #
25 # The size of each binlog file. This is rounded
26 # up to the nearest 512 byte boundary.
27 #BEANSTALKD_BINLOG_SIZE=10485760
0 description "simple, fast work queue"
1
2 start on filesystem
3 stop on runlevel [!2345]
4
5 respawn
6 respawn limit 5 2
7
8 exec su nobody -c 'exec /usr/bin/beanstalkd'
+0
-304
beanstalkd.c less more
0 /* beanstalk - fast, general-purpose work queue */
1
2 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "config.h"
19
20 #include <signal.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <errno.h>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <sys/resource.h>
27 #include <sys/socket.h>
28 #include <netinet/in.h>
29 #include <arpa/inet.h>
30 #include <sys/types.h>
31 #include <unistd.h>
32 #include <pwd.h>
33 #include <event.h>
34 #include <limits.h>
35
36 #include "net.h"
37 #include "util.h"
38 #include "prot.h"
39 #include "binlog.h"
40
41 static char *user = NULL;
42 static int detach = 0;
43 static char *port = "11300";
44 static char *host_addr;
45
46 static void
47 nullfd(int fd, int flags)
48 {
49 int r;
50
51 close(fd);
52 r = open("/dev/null", flags);
53 if (r != fd) twarn("open(\"/dev/null\")"), exit(1);
54 }
55
56 static void
57 dfork()
58 {
59 pid_t p;
60
61 p = fork();
62 if (p == -1) exit(1);
63 if (p) exit(0);
64 }
65
66 static void
67 daemonize()
68 {
69 int r;
70
71 r = chdir("/");
72 if (r) return twarn("chdir");
73
74 nullfd(0, O_RDONLY);
75 nullfd(1, O_WRONLY);
76 nullfd(2, O_WRONLY);
77 umask(0);
78 dfork();
79 setsid();
80 dfork();
81 }
82
83 static void
84 su(const char *user) {
85 int r;
86 struct passwd *pwent;
87
88 errno = 0;
89 pwent = getpwnam(user);
90 if (errno) twarn("getpwnam(\"%s\")", user), exit(32);
91 if (!pwent) twarnx("getpwnam(\"%s\"): no such user", user), exit(33);
92
93 r = setgid(pwent->pw_gid);
94 if (r == -1) twarn("setgid(%d \"%s\")", pwent->pw_gid, user), exit(34);
95
96 r = setuid(pwent->pw_uid);
97 if (r == -1) twarn("setuid(%d \"%s\")", pwent->pw_uid, user), exit(34);
98 }
99
100 void
101 exit_cleanly(int sig)
102 {
103 binlog_shutdown();
104 exit(0);
105 }
106
107
108 static void
109 set_sig_handlers()
110 {
111 int r;
112 struct sigaction sa;
113
114 sa.sa_handler = SIG_IGN;
115 sa.sa_flags = 0;
116 r = sigemptyset(&sa.sa_mask);
117 if (r == -1) twarn("sigemptyset()"), exit(111);
118
119 r = sigaction(SIGPIPE, &sa, 0);
120 if (r == -1) twarn("sigaction(SIGPIPE)"), exit(111);
121
122 sa.sa_handler = enter_drain_mode;
123 r = sigaction(SIGUSR1, &sa, 0);
124 if (r == -1) twarn("sigaction(SIGUSR1)"), exit(111);
125
126 sa.sa_handler = exit_cleanly;
127 r = sigaction(SIGINT, &sa, 0);
128 if (r == -1) twarn("sigaction(SIGINT)"), exit(111);
129
130 sa.sa_handler = exit_cleanly;
131 r = sigaction(SIGTERM, &sa, 0);
132 if (r == -1) twarn("sigaction(SIGTERM)"), exit(111);
133 }
134
135 /* This is a workaround for a mystifying workaround in libevent's epoll
136 * implementation. The epoll_init() function creates an epoll fd with space to
137 * handle RLIMIT_NOFILE - 1 fds, accompanied by the following puzzling comment:
138 * "Solaris is somewhat retarded - it's important to drop backwards
139 * compatibility when making changes. So, don't dare to put rl.rlim_cur here."
140 * This is presumably to work around a bug in Solaris, but it has the
141 * unfortunate side-effect of causing epoll_ctl() (and, therefore, event_add())
142 * to fail for a valid fd if we have hit the limit of open fds. That makes it
143 * hard to provide reasonable behavior in that situation. So, let's reduce the
144 * real value of RLIMIT_NOFILE by one, after epoll_init() has run. */
145 static void
146 nudge_fd_limit()
147 {
148 int r;
149 struct rlimit rl;
150
151 r = getrlimit(RLIMIT_NOFILE, &rl);
152 if (r != 0) twarn("getrlimit(RLIMIT_NOFILE)"), exit(2);
153
154 rl.rlim_cur--;
155
156 r = setrlimit(RLIMIT_NOFILE, &rl);
157 if (r != 0) twarn("setrlimit(RLIMIT_NOFILE)"), exit(2);
158 }
159
160 static void
161 usage(char *msg, char *arg)
162 {
163 if (arg) warnx("%s: %s", msg, arg);
164 fprintf(stderr, "Use: %s [OPTIONS]\n"
165 "\n"
166 "Options:\n"
167 " -d detach\n"
168 " -b DIR binlog directory (must be absolute path if used with -d)\n"
169 " -f MS fsync at most once every MS milliseconds"
170 " (use -f 0 for \"always fsync\")\n"
171 " -F never fsync (default)\n"
172 " -l ADDR listen on address (default is 0.0.0.0)\n"
173 " -p PORT listen on port (default is 11300)\n"
174 " -u USER become user and group\n"
175 " -z BYTES set the maximum job size in bytes (default is %d)\n"
176 " -s BYTES set the size of each binlog file (default is %d)\n"
177 #ifndef HAVE_POSIX_FALLOCATE
178 " (will be rounded up to a multiple of 512 bytes)\n"
179 #endif
180 " -v show version information\n"
181 " -h show this help\n",
182 progname, JOB_DATA_SIZE_LIMIT_DEFAULT, BINLOG_SIZE_LIMIT_DEFAULT);
183 exit(arg ? 5 : 0);
184 }
185
186 static size_t
187 parse_size_t(char *str)
188 {
189 char r, x;
190 size_t size;
191
192 r = sscanf(str, "%zu%c", &size, &x);
193 if (1 != r) usage("invalid size", str);
194 return size;
195 }
196
197 static char *
198 require_arg(char *opt, char *arg)
199 {
200 if (!arg) usage("option requires an argument", opt);
201 return arg;
202 }
203
204 static void
205 opts(int argc, char **argv)
206 {
207 int i;
208
209 for (i = 1; i < argc; ++i) {
210 if (argv[i][0] != '-') usage("unknown option", argv[i]);
211 if (argv[i][1] == 0 || argv[i][2] != 0) usage("unknown option",argv[i]);
212 switch (argv[i][1]) {
213 case 'd':
214 detach = 1;
215 break;
216 case 'p':
217 port = require_arg("-p", argv[++i]);
218 break;
219 case 'l':
220 host_addr = require_arg("-l", argv[++i]);
221 break;
222 case 'z':
223 job_data_size_limit = parse_size_t(require_arg("-z",
224 argv[++i]));
225 break;
226 case 's':
227 binlog_size_limit = parse_size_t(require_arg("-s", argv[++i]));
228 break;
229 case 'f':
230 fsync_throttle_ms = parse_size_t(require_arg("-f", argv[++i]));
231 enable_fsync = 1;
232 break;
233 case 'F':
234 enable_fsync = 0;
235 break;
236 case 'u':
237 user = require_arg("-u", argv[++i]);
238 break;
239 case 'b':
240 binlog_dir = require_arg("-b", argv[++i]);
241 break;
242 case 'h':
243 usage(NULL, NULL);
244 case 'v':
245 printf("beanstalkd %s\n", VERSION);
246 exit(0);
247 default:
248 usage("unknown option", argv[i]);
249 }
250 }
251 }
252
253 int
254 main(int argc, char **argv)
255 {
256 int r;
257 struct event_base *ev_base;
258 struct job binlog_jobs = {};
259
260 progname = argv[0];
261 opts(argc, argv);
262
263 if (detach && binlog_dir) {
264 if (binlog_dir[0] != '/') {
265 warnx("The -b option requires an absolute path when used with -d.");
266 usage("Path is not absolute", binlog_dir);
267 }
268 }
269
270 job_init();
271 prot_init();
272
273 /* We want to make sure that only one beanstalkd tries to use the binlog
274 * directory at a time. So acquire a lock now and never release it. */
275 if (binlog_dir) {
276 r = binlog_lock();
277 if (!r) twarnx("failed to lock binlog dir %s", binlog_dir), exit(10);
278 }
279
280 r = make_server_socket(host_addr, port);
281 if (r == -1) twarnx("make_server_socket()"), exit(111);
282
283 if (user) su(user);
284 ev_base = event_init();
285 set_sig_handlers();
286 nudge_fd_limit();
287
288 unbrake((evh) h_accept);
289
290 binlog_jobs.prev = binlog_jobs.next = &binlog_jobs;
291 binlog_init(&binlog_jobs);
292 prot_replay_binlog(&binlog_jobs);
293
294 if (detach) {
295 daemonize();
296 event_reinit(ev_base);
297 }
298
299 event_dispatch();
300 twarnx("event_dispatch error");
301 binlog_shutdown();
302 return 0;
303 }
33 %define beanstalkd_logdir %{_localstatedir}/log/beanstalkd
44
55 Name: beanstalkd
6 Version: 1.4.6
6 Version: 1.5
77 Release: 0%{?dist}
88 Summary: A simple, fast workqueue service
99
1313 Source0: http://xph.us/dist/%{name}/rel/%{name}-%{version}.tar.gz
1414
1515 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
16 BuildRequires: libevent-devel
1716
1817 Requires(pre): %{_sbindir}/useradd
1918 Requires(post): /sbin/chkconfig
6867 %files
6968 %defattr(-,root,root,-)
7069 %doc %{_defaultdocdir}/%{name}-%{version}/protocol.txt
71 %doc README COPYING README-DEVELOPERS README-TESTS doc/protocol.txt
70 %doc README COPYING doc/protocol.txt
7271 %{_initrddir}/%{name}
7372 %{_bindir}/%{name}
7473 %{_mandir}/man1/%{name}.1.gz
+0
-89
beanstalkd.spec.in less more
0 %define beanstalkd_user beanstalkd
1 %define beanstalkd_group %{beanstalkd_user}
2 %define beanstalkd_home %{_localstatedir}/lib/beanstalkd
3 %define beanstalkd_logdir %{_localstatedir}/log/beanstalkd
4
5 Name: beanstalkd
6 Version: @VERSION@
7 Release: 0%{?dist}
8 Summary: A simple, fast workqueue service
9
10 Group: System Environment/Daemons
11 License: GPLv3+
12 URL: http://xph.us/software/%{name}/
13 Source0: http://xph.us/dist/%{name}/rel/%{name}-%{version}.tar.gz
14
15 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
16 BuildRequires: libevent-devel
17
18 Requires(pre): %{_sbindir}/useradd
19 Requires(post): /sbin/chkconfig
20 Requires(preun): /sbin/chkconfig, /sbin/service
21 Requires(postun): /sbin/service
22
23
24 %description
25 Beanstalk is a simple, fast workqueue service. Its interface is generic, but
26 was originally designed for reducing the latency of page views in high-volume
27 web applications by running time-consuming tasks asynchronously.
28
29
30 %prep
31 %setup -q
32 if [ ! -e configure ]; then
33 sh buildconf.sh
34 fi
35
36 %build
37 %configure --disable-rpath --docdir=%{_defaultdocdir}/%{name}-%{version}
38 make %{?_smp_mflags}
39
40 %install
41 rm -rf $RPM_BUILD_ROOT
42 make install DESTDIR=$RPM_BUILD_ROOT
43 %{__install} -p -D -m 0644 doc/%{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1
44 %{__install} -p -D -m 0755 scripts/%{name}.init %{buildroot}%{_initrddir}/%{name}
45 %{__install} -p -D -m 0644 scripts/%{name}.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name}
46
47
48 %clean
49 rm -rf $RPM_BUILD_ROOT
50
51 %pre
52 %{_sbindir}/useradd -c "beanstalkd user" -s /bin/false -r -m -d %{beanstalkd_home} %{beanstalkd_user} 2>/dev/null || :
53
54 %post
55 /sbin/chkconfig --add %{name}
56
57 %preun
58 if [ $1 = 0 ]; then
59 /sbin/service %{name} stop >/dev/null 2>&1
60 /sbin/chkconfig --del %{name}
61 fi
62
63 %postun
64 if [ $1 -ge 1 ]; then
65 /sbin/service %{name} condrestart > /dev/null 2>&1 || :
66 fi
67
68 %files
69 %defattr(-,root,root,-)
70 %doc %{_defaultdocdir}/%{name}-%{version}/protocol.txt
71 %doc README COPYING README-DEVELOPERS README-TESTS doc/protocol.txt
72 %{_initrddir}/%{name}
73 %{_bindir}/%{name}
74 %{_mandir}/man1/%{name}.1.gz
75 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
76
77
78 %changelog
79 * Thu Oct 1 2009 Keith Rarick <kr@xph.us> - 1.4-0
80 - Convert this file to an autoconf template
81 - Tweak the summary and description
82
83 * Sun Jan 4 2009 Ask Bjørn Hansen <ask@develooper.com> - 1.2-0
84 - 1.2-tobe
85 - Use man page and .init/sysconfig scripts from .tar.gz
86
87 * Sat Nov 22 2008 Jeremy Hinegardner <jeremy at hinegardner dot org> - 1.1-1
88 - initial spec creation
+0
-803
binlog.c less more
0 /* binlog.c - binary log implementation */
1
2 /* Copyright (C) 2008 Graham Barr
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "config.h"
19
20 #if HAVE_STDINT_H
21 # include <stdint.h>
22 #endif /* else we get int types from config.h */
23
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <fcntl.h>
27 #include <unistd.h>
28 #include <string.h>
29 #include <errno.h>
30 #include <dirent.h>
31 #include <sys/resource.h>
32 #include <sys/param.h>
33 #include <sys/uio.h>
34 #include <sys/stat.h>
35 #include <stdarg.h>
36 #include <limits.h>
37 #include <stddef.h>
38
39 #include "tube.h"
40 #include "job.h"
41 #include "binlog.h"
42 #include "util.h"
43 #include "port.h"
44
45 typedef struct binlog *binlog;
46
47 struct binlog {
48 binlog next;
49 unsigned int refs;
50 int fd;
51 size_t free;
52 size_t reserved;
53 char path[];
54 };
55
56 /* max size we will create a log file */
57 size_t binlog_size_limit = BINLOG_SIZE_LIMIT_DEFAULT;
58
59 int enable_fsync = 0;
60 size_t fsync_throttle_ms = 0;
61 uint64_t last_fsync = 0;
62
63 char *binlog_dir = NULL;
64 static int binlog_index = 0;
65 static int binlog_version = 5;
66 static int lock_fd;
67
68 static binlog oldest_binlog = 0,
69 current_binlog = 0,
70 newest_binlog = 0;
71
72 static const size_t job_record_size = offsetof(struct job, pad);
73
74 static int
75 binlog_scan_dir()
76 {
77 DIR *dirp;
78 struct dirent *dp;
79 long min = 0;
80 long max = 0;
81 long val;
82 char *endptr;
83 size_t name_len;
84
85 dirp = opendir(binlog_dir);
86 if (!dirp) return 0;
87
88 while ((dp = readdir(dirp)) != NULL) {
89 name_len = strlen(dp->d_name);
90 if (name_len > 7 && !strncmp("binlog.", dp->d_name, 7)) {
91 val = strtol(dp->d_name + 7, &endptr, 10);
92 if (endptr && *endptr == 0) {
93 if (max == 0 || val > max) max = val;
94 if (min == 0 || val < min) min = val;
95 }
96 }
97 }
98
99 closedir(dirp);
100 binlog_index = (int) max;
101 return (int) min;
102 }
103
104 static void
105 binlog_remove_oldest()
106 {
107 binlog b = oldest_binlog;
108
109 if (!b) return;
110
111 oldest_binlog = b->next;
112
113 unlink(b->path);
114 free(b);
115 }
116
117 static binlog
118 binlog_iref(binlog b)
119 {
120 if (b) b->refs++;
121 return b;
122 }
123
124 static void
125 binlog_dref(binlog b)
126 {
127 if (!b) return;
128 if (b->refs < 1) return twarnx("refs is zero for binlog: %s", b->path);
129
130 --b->refs;
131 if (b->refs < 1) {
132 while (oldest_binlog && oldest_binlog->refs == 0) {
133 binlog_remove_oldest();
134 }
135 }
136 }
137
138 /*
139 static void
140 binlog_warn(int fd, const char* path, const char *msg)
141 {
142 warnx("WARNING, %s at %s:%u.\n%s", msg, path, lseek(fd, 0, SEEK_CUR),
143 " Continuing. You may be missing data.");
144 }
145 */
146
147 #define binlog_warn(b, fmt, args...) \
148 warnx("WARNING, " fmt " at %s:%u. %s: ", \
149 ##args, b->path, lseek(b->fd, 0, SEEK_CUR), \
150 "Continuing. You may be missing data.")
151
152 static void
153 binlog_read_log_file(binlog b, job binlog_jobs)
154 {
155 struct job js;
156 tube t;
157 job j;
158 char tubename[MAX_TUBE_NAME_LEN];
159 size_t namelen;
160 ssize_t r;
161 int version;
162
163 r = read(b->fd, &version, sizeof(version));
164 if (r == -1) return twarn("read()");
165 if (r < sizeof(version)) {
166 return binlog_warn(b, "EOF while reading version record");
167 }
168
169 if (version != binlog_version) {
170 return warnx("%s: binlog version mismatch %d %d", b->path, version,
171 binlog_version);
172 }
173
174 while (read(b->fd, &namelen, sizeof(size_t)) == sizeof(size_t)) {
175 if (namelen >= MAX_TUBE_NAME_LEN) {
176 return binlog_warn(b, "namelen %d exceeds maximum of %d", namelen, MAX_TUBE_NAME_LEN - 1);
177 }
178
179 if (namelen > 0) {
180 r = read(b->fd, tubename, namelen);
181 if (r == -1) return twarn("read()");
182 if (r < namelen) {
183 lseek(b->fd, SEEK_CUR, 0);
184 return binlog_warn(b, "EOF while reading tube name");
185 }
186 }
187
188 tubename[namelen] = '\0';
189 r = read(b->fd, &js, job_record_size);
190 if (r == -1) return twarn("read()");
191 if (r < job_record_size) {
192 return binlog_warn(b, "EOF while reading job record");
193 }
194
195 if (!js.id) break;
196
197 j = job_find(js.id);
198 switch (js.state) {
199 case JOB_STATE_INVALID:
200 if (j) {
201 job_remove(j);
202 binlog_dref(j->binlog);
203 job_free(j);
204 j = NULL;
205 }
206 break;
207 case JOB_STATE_READY:
208 case JOB_STATE_DELAYED:
209 if (!j && namelen > 0) {
210 t = tube_find_or_make(tubename);
211 j = make_job_with_id(js.pri, js.delay, js.ttr, js.body_size,
212 t, js.id);
213 j->next = j->prev = j;
214 j->created_at = js.created_at;
215 job_insert(binlog_jobs, j);
216 }
217 if (js.body_size && namelen > 0) { /* namelen > 0 only on new jobs */
218 if (js.body_size > j->body_size) {
219 warnx("job size increased from %zu to %zu", j->body_size,
220 js.body_size);
221 job_remove(j);
222 binlog_dref(j->binlog);
223 job_free(j);
224 return binlog_warn(b, "EOF while reading job body");
225 }
226 r = read(b->fd, j->body, js.body_size);
227 if (r == -1) return twarn("read()");
228 if (r < js.body_size) {
229 warnx("dropping incomplete job %llu", j->id);
230 job_remove(j);
231 binlog_dref(j->binlog);
232 job_free(j);
233 return binlog_warn(b, "EOF while reading job body");
234 }
235 }
236 break;
237 }
238 if (j) {
239 j->state = js.state;
240 j->deadline_at = js.deadline_at;
241 j->pri = js.pri;
242 j->delay = js.delay;
243 j->ttr = js.ttr;
244 j->timeout_ct = js.timeout_ct;
245 j->release_ct = js.release_ct;
246 j->bury_ct = js.bury_ct;
247 j->kick_ct = js.kick_ct;
248
249 /* this is a complete record, so we can move the binlog ref */
250 if (namelen && js.body_size) {
251 binlog_dref(j->binlog);
252 j->binlog = binlog_iref(b);
253 }
254 }
255 }
256 }
257
258 static void
259 binlog_close(binlog b)
260 {
261 int r;
262
263 if (!b) return;
264 if (b->fd < 0) return;
265 if (b->free) {
266 // Some compilers give a warning if the return value of ftruncate is
267 // ignored. So we pretend to use it.
268 r = ftruncate(b->fd, binlog_size_limit - b->free);
269 if (r == -1) {
270 // Nothing we can do. The user might see warnings next startup.
271 }
272 }
273 close(b->fd);
274 b->fd = -1;
275 binlog_dref(b);
276 }
277
278 static binlog
279 make_binlog(char *path)
280 {
281 binlog b;
282
283 b = (binlog) malloc(sizeof(struct binlog) + strlen(path) + 1);
284 if (!b) return twarnx("OOM"), (binlog) 0;
285 strcpy(b->path, path);
286 b->refs = 0;
287 b->next = NULL;
288 b->fd = -1;
289 b->free = 0;
290 b->reserved = 0;
291 return b;
292 }
293
294 static binlog
295 make_next_binlog()
296 {
297 int r;
298 char path[PATH_MAX];
299
300 if (!binlog_dir) return NULL;
301
302 r = snprintf(path, PATH_MAX, "%s/binlog.%d", binlog_dir, ++binlog_index);
303 if (r > PATH_MAX) return twarnx("path too long: %s", binlog_dir), (binlog)0;
304
305 return make_binlog(path);
306 }
307
308 static binlog
309 add_binlog(binlog b)
310 {
311 if (newest_binlog) newest_binlog->next = b;
312 newest_binlog = b;
313 if (!oldest_binlog) oldest_binlog = b;
314
315 return b;
316 }
317
318 static int
319 beanstalkd_fallocate(int fd, off_t offset, off_t len)
320 {
321 off_t i;
322 ssize_t w;
323 off_t p;
324 #define ZERO_BUF_SIZE 512
325 char buf[ZERO_BUF_SIZE] = {}; /* initialize to zero */
326
327 /* we only support a 0 offset */
328 if (offset != 0) return EINVAL;
329
330 if (len <= 0) return EINVAL;
331
332 for (i = 0; i < len; i += w) {
333 w = write(fd, &buf, ZERO_BUF_SIZE);
334 if (w == -1) return errno;
335 }
336
337 p = lseek(fd, 0, SEEK_SET);
338 if (p == -1) return errno;
339
340 return 0;
341 }
342
343 static void
344 binlog_open(binlog log, size_t *written)
345 {
346 int fd;
347 size_t bytes_written;
348
349 if (written) *written = 0;
350
351 if (!binlog_iref(log)) return;
352
353 fd = open(log->path, O_WRONLY | O_CREAT, 0400);
354
355 if (fd < 0) return twarn("Cannot open binlog %s", log->path);
356
357 #ifdef HAVE_POSIX_FALLOCATE
358 {
359 int r;
360 r = posix_fallocate(fd, 0, binlog_size_limit);
361 if (r == EINVAL) {
362 r = beanstalkd_fallocate(fd, 0, binlog_size_limit);
363 }
364 if (r) {
365 close(fd);
366 binlog_dref(log);
367 errno = r;
368 return twarn("Cannot allocate space for binlog %s", log->path);
369 }
370 }
371 #else
372 /* Allocate space in a slow but portable way. */
373 {
374 int r;
375 r = beanstalkd_fallocate(fd, 0, binlog_size_limit);
376 if (r) {
377 close(fd);
378 binlog_dref(log);
379 errno = r;
380 return twarn("Cannot allocate space for binlog %s", log->path);
381 }
382 }
383 #endif
384
385 bytes_written = write(fd, &binlog_version, sizeof(int));
386 if (written) *written = bytes_written;
387
388 if (bytes_written < sizeof(int)) {
389 twarn("Cannot write to binlog");
390 close(fd);
391 binlog_dref(log);
392 return;
393 }
394
395 log->fd = fd;
396 }
397
398 /* returns 1 on success, 0 on error. */
399 static int
400 binlog_use_next()
401 {
402 binlog next;
403
404 if (!current_binlog) return 0;
405
406 next = current_binlog->next;
407
408 if (!next) return 0;
409
410 /* assert(current_binlog->reserved == 0); */
411
412 binlog_close(current_binlog);
413 current_binlog = next;
414
415 return 1;
416 }
417
418 void
419 binlog_shutdown()
420 {
421 binlog_use_next();
422 binlog_close(current_binlog);
423 }
424
425 /* Returns the number of jobs successfully written (either 0 or 1).
426
427 If this fails, something is seriously wrong. It should never fail because of
428 a full disk. (The binlog_reserve_space_* functions, on the other hand, can
429 fail because of a full disk.)
430
431 If we are not using the binlog at all (!current_binlog), then we pretend to
432 have made a successful write and return 1. */
433 int
434 binlog_write_job(job j)
435 {
436 ssize_t written;
437 size_t tube_namelen, to_write = 0;
438 struct iovec vec[4], *vptr;
439 int vcnt = 3, r;
440 uint64_t now;
441
442 if (!current_binlog) return 1;
443 tube_namelen = 0;
444
445 vec[0].iov_base = (char *) &tube_namelen;
446 to_write += vec[0].iov_len = sizeof(size_t);
447
448 vec[1].iov_base = j->tube->name;
449 vec[1].iov_len = 0;
450
451 vec[2].iov_base = (char *) j;
452 to_write += vec[2].iov_len = job_record_size;
453
454 if (j->state == JOB_STATE_READY || j->state == JOB_STATE_DELAYED ||
455 j->state == JOB_STATE_BURIED) {
456 if (!j->binlog) {
457 tube_namelen = strlen(j->tube->name);
458 to_write += vec[1].iov_len = tube_namelen;
459 vcnt = 4;
460 vec[3].iov_base = j->body;
461 to_write += vec[3].iov_len = j->body_size;
462 }
463 } else if (j->state == JOB_STATE_INVALID) {
464 if (j->binlog) binlog_dref(j->binlog);
465 j->binlog = NULL;
466 } else {
467 return twarnx("unserializable job state: %d", j->state), 0;
468 }
469
470 if (to_write > current_binlog->reserved) {
471 r = binlog_use_next();
472 if (!r) return twarnx("failed to use next binlog"), 0;
473 }
474
475 if (j->state && !j->binlog) j->binlog = binlog_iref(current_binlog);
476
477 while (to_write > 0) {
478 written = writev(current_binlog->fd, vec, vcnt);
479
480 if (written < 0) {
481 if (errno == EAGAIN) continue;
482 if (errno == EINTR) continue;
483
484 twarn("writev");
485 binlog_close(current_binlog);
486 current_binlog = 0;
487 return 0;
488 }
489
490 current_binlog->reserved -= written;
491 j->reserved_binlog_space -= written;
492
493 to_write -= written;
494 if (to_write > 0 && written > 0) {
495 for (vptr = vec; written >= vptr->iov_len; vptr++) {
496 written -= vptr->iov_len;
497 vptr->iov_len = 0;
498 }
499 vptr->iov_base = (char *) vptr->iov_base + written;
500 vptr->iov_len -= written;
501 }
502 }
503
504 now = now_usec() / 1000; /* usec -> msec */
505 if (enable_fsync && now - last_fsync >= fsync_throttle_ms) {
506 r = fdatasync(current_binlog->fd);
507 if (r == -1) return twarn("fdatasync"), 0;
508 last_fsync = now;
509 }
510
511 return 1;
512 }
513
514 static binlog
515 make_future_binlog()
516 {
517 binlog b;
518 size_t header;
519
520 /* open a new binlog with more space to reserve */
521 b = make_next_binlog();
522 if (!b) return twarnx("error making next binlog"), (binlog) 0;
523 binlog_open(b, &header);
524
525 /* open failed, so we can't reserve any space */
526 if (b->fd < 0) {
527 free(b);
528 return 0;
529 }
530
531 b->free = binlog_size_limit - header;
532 b->reserved = 0;
533 return b;
534 }
535
536 static int
537 can_move_reserved(size_t n, binlog from, binlog to)
538 {
539 return from->reserved >= n && to->free >= n;
540 }
541
542 static void
543 move_reserved(size_t n, binlog from, binlog to)
544 {
545 from->reserved -= n;
546 from->free += n;
547 to->reserved += n;
548 to->free -= n;
549 }
550
551 static size_t
552 ensure_free_space(size_t n)
553 {
554 binlog fb;
555
556 if (newest_binlog && newest_binlog->free >= n) return n;
557
558 /* open a new binlog */
559 fb = make_future_binlog();
560 if (!fb) return twarnx("make_future_binlog"), 0;
561
562 add_binlog(fb);
563 return n;
564 }
565
566 /* Ensures:
567 * 1: b->reserved is congruent to n (mod z).
568 * 2: all future binlogs ->reserved is congruent to 0 (mod z).
569 * Returns t on success, and 0 on failure. (Therefore t should be nonzero.) */
570 static size_t
571 maintain_invariants_iter(binlog b, size_t n, size_t t)
572 {
573 size_t reserved_later, remainder, complement, z, r;
574
575 /* In this function, reserved bytes are conserved (they are neither created
576 * nor destroyed). We just move them around to preserve the invariant. We
577 * might have to create new free space (i.e. allocate a new binlog file),
578 * though. */
579
580 if (!b) return t;
581
582 z = sizeof(size_t) + job_record_size;
583 reserved_later = b->reserved - n;
584 remainder = reserved_later % z;
585 if (remainder == 0) return maintain_invariants_iter(b->next, 0, t);
586
587 if (b == newest_binlog) {
588 twarnx("newest binlog has invalid %zd reserved", b->reserved);
589 /* We have failed, so undo the reservation and return 0. */
590 if (newest_binlog->reserved >= t) {
591 newest_binlog->reserved -= t;
592 } else {
593 twarnx("failed to unreserve %zd bytes", t); /* can't happen */
594 }
595 return 0;
596 }
597
598 complement = z - remainder;
599 if (can_move_reserved(complement, newest_binlog, b)) {
600 move_reserved(complement, newest_binlog, b);
601 return maintain_invariants_iter(b->next, 0, t);
602 }
603
604 r = ensure_free_space(remainder);
605 if (r != remainder) {
606 twarnx("ensure_free_space");
607 /* We have failed, so undo the reservation and return 0. */
608 if (newest_binlog->reserved >= t) {
609 newest_binlog->reserved -= t;
610 } else {
611 twarnx("failed to unreserve %zd bytes", t); /* can't happen */
612 }
613 return 0;
614 }
615 move_reserved(remainder, b, newest_binlog);
616 return maintain_invariants_iter(b->next, 0, t);
617 }
618
619
620 /* Preserve some invariants immediately after any space reservation
621 * (where z is the size of a delete record in the binlog).
622 * Invariant 1: current_binlog->reserved >= n.
623 * Invariant 2: current_binlog->reserved is congruent to n (mod z).
624 * Invariant 3: all future binlogs ->reserved is congruent to 0 (mod z). */
625 static size_t
626 maintain_invariants(size_t n)
627 {
628 size_t r;
629
630 /* In this function, reserved bytes are conserved (they are neither created
631 * nor destroyed). We just move them around to preserve the invariant. We
632 * might have to create new free space (i.e. allocate a new binlog file),
633 * though. */
634
635 /* Invariant 1. */
636 /* This is a loop, but it's guaranteed to run at most once. The proof is
637 * left as an exercise for the reader. */
638 while (current_binlog->reserved < n) {
639 size_t to_move = current_binlog->reserved;
640
641 r = ensure_free_space(to_move);
642 if (r != to_move) {
643 twarnx("ensure_free_space");
644 /* We have failed, so undo the reservation and return 0. */
645 if (newest_binlog->reserved >= n) {
646 newest_binlog->reserved -= n;
647 } else {
648 twarnx("failed to unreserve %zd bytes", n); /* can't happen */
649 }
650 return 0;
651 }
652
653 move_reserved(to_move, current_binlog, newest_binlog);
654 binlog_use_next();
655 }
656
657 /* Invariants 2 and 3. */
658 return maintain_invariants_iter(current_binlog, n, n);
659 }
660
661 /* Returns the number of bytes successfully reserved: either 0 or n. */
662 static size_t
663 binlog_reserve_space(size_t n)
664 {
665 size_t r;
666
667 /* This return value must be nonzero but is otherwise ignored. */
668 if (!current_binlog) return 1;
669
670 if (current_binlog->free >= n) {
671 current_binlog->free -= n;
672 current_binlog->reserved += n;
673 return maintain_invariants(n);
674 }
675
676 r = ensure_free_space(n);
677 if (r != n) return twarnx("ensure_free_space"), 0;
678
679 newest_binlog->free -= n;
680 newest_binlog->reserved += n;
681 return maintain_invariants(n);
682 }
683
684 /* Returns the number of bytes reserved. */
685 size_t
686 binlog_reserve_space_put(job j)
687 {
688 size_t z = 0;
689
690 /* reserve space for the initial job record */
691 z += sizeof(size_t);
692 z += strlen(j->tube->name);
693 z += job_record_size;
694 z += j->body_size;
695
696 /* plus space for a delete to come later */
697 z += sizeof(size_t);
698 z += job_record_size;
699
700 return binlog_reserve_space(z);
701 }
702
703 size_t
704 binlog_reserve_space_update(job j)
705 {
706 size_t z = 0;
707
708 z += sizeof(size_t);
709 z += job_record_size;
710 return binlog_reserve_space(z);
711 }
712
713 int
714 binlog_lock()
715 {
716 int r;
717 struct flock lock;
718 char path[PATH_MAX];
719
720 r = snprintf(path, PATH_MAX, "%s/lock", binlog_dir);
721 if (r > PATH_MAX) return twarnx("path too long: %s", binlog_dir), 0;
722
723 lock_fd = open(path, O_WRONLY|O_CREAT, 0600);
724 if (lock_fd == -1) return twarn("open"), 0;
725
726 lock.l_type = F_WRLCK;
727 lock.l_whence = SEEK_SET;
728 lock.l_start = 0;
729 lock.l_len = 0;
730 r = fcntl(lock_fd, F_SETLK, &lock);
731 if (r) return twarn("fcntl"), 0;
732
733 return 1;
734 }
735
736 void
737 binlog_init(job binlog_jobs)
738 {
739 int binlog_index_min;
740 struct stat sbuf;
741 int fd, idx, r;
742 size_t n;
743 char path[PATH_MAX];
744 binlog b;
745
746 if (!binlog_dir) return;
747
748 /* Recover any jobs in old binlogs */
749
750 if (stat(binlog_dir, &sbuf) < 0) {
751 if (mkdir(binlog_dir, 0700) < 0) return twarn("%s", binlog_dir);
752 } else if (!(sbuf.st_mode & S_IFDIR)) {
753 twarnx("%s", binlog_dir);
754 return;
755 }
756
757 binlog_index_min = binlog_scan_dir();
758
759 if (binlog_index_min) {
760 for (idx = binlog_index_min; idx <= binlog_index; idx++) {
761 r = snprintf(path, PATH_MAX, "%s/binlog.%d", binlog_dir, idx);
762 if (r > PATH_MAX) return twarnx("path too long: %s", binlog_dir);
763
764 fd = open(path, O_RDONLY);
765
766 if (fd < 0) {
767 twarn("%s", path);
768 } else {
769 b = binlog_iref(add_binlog(make_binlog(path)));
770 b->fd = fd;
771 binlog_read_log_file(b, binlog_jobs);
772 close(fd);
773 b->fd = -1;
774 binlog_dref(b);
775 }
776 }
777
778 }
779
780
781 /* Set up for writing out new jobs */
782 n = ensure_free_space(1);
783 if (!n) return twarnx("error making first writable binlog");
784
785 current_binlog = newest_binlog;
786 }
787
788 const char *
789 binlog_oldest_index()
790 {
791 if (!oldest_binlog) return "0";
792
793 return strrchr(oldest_binlog->path, '.') + 1;
794 }
795
796 const char *
797 binlog_current_index()
798 {
799 if (!newest_binlog) return "0";
800
801 return strrchr(newest_binlog->path, '.') + 1;
802 }
+0
-46
binlog.h less more
0 /* binlog.h - binary log implementation */
1
2 /* Copyright (C) 2008 Graham Barr
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef binlog_h
19 #define binlog_h
20
21 #include "job.h"
22
23 extern char *binlog_dir;
24 extern size_t binlog_size_limit;
25 #define BINLOG_SIZE_LIMIT_DEFAULT (10 << 20)
26
27 extern int enable_fsync;
28 extern size_t fsync_throttle_ms;
29
30 void binlog_init(job binlog_jobs);
31
32 /* Return the number of locks acquired: either 0 or 1. */
33 int binlog_lock();
34
35 /* Returns the number of jobs successfully written (either 0 or 1). */
36 int binlog_write_job(job j);
37 size_t binlog_reserve_space_put(job j);
38 size_t binlog_reserve_space_update(job j);
39
40 void binlog_shutdown();
41 const char *binlog_oldest_index();
42 const char *binlog_current_index();
43
44 #endif
45
+0
-44
check-one.sh less more
0 #!/usr/bin/env bash
1
2 . "$SRCDIR/sh-tests/common.functions"
3
4 server=localhost
5 tmpdir="$TMPDIR"
6 test -z "$tmpdir" && tmpdir=/tmp
7 tmpf="${tmpdir}/bnch$$"
8 nc="$SRCDIR/sh-tests/netcat.py"
9
10 commands="$1"; shift
11 expected="$1"; shift
12
13 # Allow generic tests to specify their own behavior completely.
14 test -x $commands && exec $commands
15
16 cleanup() {
17 {
18 test -z "$bpid" || kill -9 $bpid
19 rm -f "$tmpf"
20 } >/dev/null 2>&1
21 }
22
23 catch() {
24 echo '' Interrupted
25 exit 3
26 }
27
28 trap cleanup EXIT
29 trap catch HUP INT QUIT TERM
30
31 if [ ! -x ./beanstalkd ]; then
32 echo "Executable ./beanstalkd not found; do you need to compile first?"
33 exit 2
34 fi
35
36 start_beanstalkd '' '-z 10'
37
38 # Run the test
39 fgrep -v "#" $commands | $nc $server $port > "$tmpf"
40
41 # Check the output
42 diff $expected "$tmpf"
43
66 exit 0
77 fi
88
9 one="$(dirname "$0")/check-one.sh"
10
11 for commands in "$@"; do
12 expected=${commands/.commands/.expected}
13 echo $commands
14 $one $commands $expected
9 for t in "$@"; do
10 echo $t
11 $t
1512 res=$?
16 test "$res" = 1 && echo "FAIL: $commands"
13 test "$res" = 1 && echo "FAIL: $t"
1714 test "$res" = 0 || exit 1
1815 done
+0
-71
config.h.in less more
0 /* config.h.in. Generated from configure.in by autoheader. */
1
2 /* debug build */
3 #undef BEAN_DEBUG
4
5 /* If the system defines fdatasync */
6 #undef HAVE_FDATASYNC
7
8 /* Define to 1 if you have the <inttypes.h> header file. */
9 #undef HAVE_INTTYPES_H
10
11 /* Define to 1 if you have the `event' library (-levent). */
12 #undef HAVE_LIBEVENT
13
14 /* Define to 1 if you have the <memory.h> header file. */
15 #undef HAVE_MEMORY_H
16
17 /* Define to 1 if you have the `posix_fallocate' function. */
18 #undef HAVE_POSIX_FALLOCATE
19
20 /* Define to 1 if you have the <stdint.h> header file. */
21 #undef HAVE_STDINT_H
22
23 /* Define to 1 if you have the <stdlib.h> header file. */
24 #undef HAVE_STDLIB_H
25
26 /* Define to 1 if you have the <strings.h> header file. */
27 #undef HAVE_STRINGS_H
28
29 /* Define to 1 if you have the <string.h> header file. */
30 #undef HAVE_STRING_H
31
32 /* Define to 1 if you have the <sys/stat.h> header file. */
33 #undef HAVE_SYS_STAT_H
34
35 /* Define to 1 if you have the <sys/types.h> header file. */
36 #undef HAVE_SYS_TYPES_H
37
38 /* Define to 1 if you have the <unistd.h> header file. */
39 #undef HAVE_UNISTD_H
40
41 /* Name of package */
42 #undef PACKAGE
43
44 /* Define to the address where bug reports for this package should be sent. */
45 #undef PACKAGE_BUGREPORT
46
47 /* Define to the full name of this package. */
48 #undef PACKAGE_NAME
49
50 /* Define to the full name and version of this package. */
51 #undef PACKAGE_STRING
52
53 /* Define to the one symbol short name of this package. */
54 #undef PACKAGE_TARNAME
55
56 /* Define to the home page for this package. */
57 #undef PACKAGE_URL
58
59 /* Define to the version of this package. */
60 #undef PACKAGE_VERSION
61
62 /* Define to 1 if you have the ANSI C header files. */
63 #undef STDC_HEADERS
64
65 /* Version number of package */
66 #undef VERSION
67
68 /* Define to the type of an unsigned integer type of width exactly 16 bits if
69 such a type exists and the standard includes do not define it. */
70 #undef uint16_t
+0
-6590
configure less more
0 #! /bin/sh
1 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.65.
3 #
4 #
5 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
6 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
7 # Inc.
8 #
9 #
10 # This configure script is free software; the Free Software Foundation
11 # gives unlimited permission to copy, distribute and modify it.
12 ## -------------------- ##
13 ## M4sh Initialization. ##
14 ## -------------------- ##
15
16 # Be more Bourne compatible
17 DUALCASE=1; export DUALCASE # for MKS sh
18 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
19 emulate sh
20 NULLCMD=:
21 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
22 # is contrary to our usage. Disable this feature.
23 alias -g '${1+"$@"}'='"$@"'
24 setopt NO_GLOB_SUBST
25 else
26 case `(set -o) 2>/dev/null` in #(
27 *posix*) :
28 set -o posix ;; #(
29 *) :
30 ;;
31 esac
32 fi
33
34
35 as_nl='
36 '
37 export as_nl
38 # Printing a long string crashes Solaris 7 /usr/bin/printf.
39 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
40 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
41 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
42 # Prefer a ksh shell builtin over an external printf program on Solaris,
43 # but without wasting forks for bash or zsh.
44 if test -z "$BASH_VERSION$ZSH_VERSION" \
45 && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
46 as_echo='print -r --'
47 as_echo_n='print -rn --'
48 elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
49 as_echo='printf %s\n'
50 as_echo_n='printf %s'
51 else
52 if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
53 as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
54 as_echo_n='/usr/ucb/echo -n'
55 else
56 as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
57 as_echo_n_body='eval
58 arg=$1;
59 case $arg in #(
60 *"$as_nl"*)
61 expr "X$arg" : "X\\(.*\\)$as_nl";
62 arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
63 esac;
64 expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
65 '
66 export as_echo_n_body
67 as_echo_n='sh -c $as_echo_n_body as_echo'
68 fi
69 export as_echo_body
70 as_echo='sh -c $as_echo_body as_echo'
71 fi
72
73 # The user is always right.
74 if test "${PATH_SEPARATOR+set}" != set; then
75 PATH_SEPARATOR=:
76 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
77 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
78 PATH_SEPARATOR=';'
79 }
80 fi
81
82
83 # IFS
84 # We need space, tab and new line, in precisely that order. Quoting is
85 # there to prevent editors from complaining about space-tab.
86 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
87 # splitting by setting IFS to empty value.)
88 IFS=" "" $as_nl"
89
90 # Find who we are. Look in the path if we contain no directory separator.
91 case $0 in #((
92 *[\\/]* ) as_myself=$0 ;;
93 *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
94 for as_dir in $PATH
95 do
96 IFS=$as_save_IFS
97 test -z "$as_dir" && as_dir=.
98 test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
99 done
100 IFS=$as_save_IFS
101
102 ;;
103 esac
104 # We did not find ourselves, most probably we were run as `sh COMMAND'
105 # in which case we are not to be found in the path.
106 if test "x$as_myself" = x; then
107 as_myself=$0
108 fi
109 if test ! -f "$as_myself"; then
110 $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
111 exit 1
112 fi
113
114 # Unset variables that we do not need and which cause bugs (e.g. in
115 # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
116 # suppresses any "Segmentation fault" message there. '((' could
117 # trigger a bug in pdksh 5.2.14.
118 for as_var in BASH_ENV ENV MAIL MAILPATH
119 do eval test x\${$as_var+set} = xset \
120 && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
121 done
122 PS1='$ '
123 PS2='> '
124 PS4='+ '
125
126 # NLS nuisances.
127 LC_ALL=C
128 export LC_ALL
129 LANGUAGE=C
130 export LANGUAGE
131
132 # CDPATH.
133 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
134
135 if test "x$CONFIG_SHELL" = x; then
136 as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
137 emulate sh
138 NULLCMD=:
139 # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
140 # is contrary to our usage. Disable this feature.
141 alias -g '\${1+\"\$@\"}'='\"\$@\"'
142 setopt NO_GLOB_SUBST
143 else
144 case \`(set -o) 2>/dev/null\` in #(
145 *posix*) :
146 set -o posix ;; #(
147 *) :
148 ;;
149 esac
150 fi
151 "
152 as_required="as_fn_return () { (exit \$1); }
153 as_fn_success () { as_fn_return 0; }
154 as_fn_failure () { as_fn_return 1; }
155 as_fn_ret_success () { return 0; }
156 as_fn_ret_failure () { return 1; }
157
158 exitcode=0
159 as_fn_success || { exitcode=1; echo as_fn_success failed.; }
160 as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
161 as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
162 as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
163 if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
164
165 else
166 exitcode=1; echo positional parameters were not saved.
167 fi
168 test x\$exitcode = x0 || exit 1"
169 as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
170 as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
171 eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
172 test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
173 test \$(( 1 + 1 )) = 2 || exit 1"
174 if (eval "$as_required") 2>/dev/null; then :
175 as_have_required=yes
176 else
177 as_have_required=no
178 fi
179 if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
180
181 else
182 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
183 as_found=false
184 for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
185 do
186 IFS=$as_save_IFS
187 test -z "$as_dir" && as_dir=.
188 as_found=:
189 case $as_dir in #(
190 /*)
191 for as_base in sh bash ksh sh5; do
192 # Try only shells that exist, to save several forks.
193 as_shell=$as_dir/$as_base
194 if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
195 { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
196 CONFIG_SHELL=$as_shell as_have_required=yes
197 if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
198 break 2
199 fi
200 fi
201 done;;
202 esac
203 as_found=false
204 done
205 $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
206 { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
207 CONFIG_SHELL=$SHELL as_have_required=yes
208 fi; }
209 IFS=$as_save_IFS
210
211
212 if test "x$CONFIG_SHELL" != x; then :
213 # We cannot yet assume a decent shell, so we have to provide a
214 # neutralization value for shells without unset; and this also
215 # works around shells that cannot unset nonexistent variables.
216 BASH_ENV=/dev/null
217 ENV=/dev/null
218 (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
219 export CONFIG_SHELL
220 exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
221 fi
222
223 if test x$as_have_required = xno; then :
224 $as_echo "$0: This script requires a shell more modern than all"
225 $as_echo "$0: the shells that I found on your system."
226 if test x${ZSH_VERSION+set} = xset ; then
227 $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
228 $as_echo "$0: be upgraded to zsh 4.3.4 or later."
229 else
230 $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
231 $0: including any error possibly output before this
232 $0: message. Then install a modern shell, or manually run
233 $0: the script under such a shell if you do have one."
234 fi
235 exit 1
236 fi
237 fi
238 fi
239 SHELL=${CONFIG_SHELL-/bin/sh}
240 export SHELL
241 # Unset more variables known to interfere with behavior of common tools.
242 CLICOLOR_FORCE= GREP_OPTIONS=
243 unset CLICOLOR_FORCE GREP_OPTIONS
244
245 ## --------------------- ##
246 ## M4sh Shell Functions. ##
247 ## --------------------- ##
248 # as_fn_unset VAR
249 # ---------------
250 # Portably unset VAR.
251 as_fn_unset ()
252 {
253 { eval $1=; unset $1;}
254 }
255 as_unset=as_fn_unset
256
257 # as_fn_set_status STATUS
258 # -----------------------
259 # Set $? to STATUS, without forking.
260 as_fn_set_status ()
261 {
262 return $1
263 } # as_fn_set_status
264
265 # as_fn_exit STATUS
266 # -----------------
267 # Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
268 as_fn_exit ()
269 {
270 set +e
271 as_fn_set_status $1
272 exit $1
273 } # as_fn_exit
274
275 # as_fn_mkdir_p
276 # -------------
277 # Create "$as_dir" as a directory, including parents if necessary.
278 as_fn_mkdir_p ()
279 {
280
281 case $as_dir in #(
282 -*) as_dir=./$as_dir;;
283 esac
284 test -d "$as_dir" || eval $as_mkdir_p || {
285 as_dirs=
286 while :; do
287 case $as_dir in #(
288 *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
289 *) as_qdir=$as_dir;;
290 esac
291 as_dirs="'$as_qdir' $as_dirs"
292 as_dir=`$as_dirname -- "$as_dir" ||
293 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
294 X"$as_dir" : 'X\(//\)[^/]' \| \
295 X"$as_dir" : 'X\(//\)$' \| \
296 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
297 $as_echo X"$as_dir" |
298 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
299 s//\1/
300 q
301 }
302 /^X\(\/\/\)[^/].*/{
303 s//\1/
304 q
305 }
306 /^X\(\/\/\)$/{
307 s//\1/
308 q
309 }
310 /^X\(\/\).*/{
311 s//\1/
312 q
313 }
314 s/.*/./; q'`
315 test -d "$as_dir" && break
316 done
317 test -z "$as_dirs" || eval "mkdir $as_dirs"
318 } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
319
320
321 } # as_fn_mkdir_p
322 # as_fn_append VAR VALUE
323 # ----------------------
324 # Append the text in VALUE to the end of the definition contained in VAR. Take
325 # advantage of any shell optimizations that allow amortized linear growth over
326 # repeated appends, instead of the typical quadratic growth present in naive
327 # implementations.
328 if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
329 eval 'as_fn_append ()
330 {
331 eval $1+=\$2
332 }'
333 else
334 as_fn_append ()
335 {
336 eval $1=\$$1\$2
337 }
338 fi # as_fn_append
339
340 # as_fn_arith ARG...
341 # ------------------
342 # Perform arithmetic evaluation on the ARGs, and store the result in the
343 # global $as_val. Take advantage of shells that can avoid forks. The arguments
344 # must be portable across $(()) and expr.
345 if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
346 eval 'as_fn_arith ()
347 {
348 as_val=$(( $* ))
349 }'
350 else
351 as_fn_arith ()
352 {
353 as_val=`expr "$@" || test $? -eq 1`
354 }
355 fi # as_fn_arith
356
357
358 # as_fn_error ERROR [LINENO LOG_FD]
359 # ---------------------------------
360 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
361 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
362 # script with status $?, using 1 if that was 0.
363 as_fn_error ()
364 {
365 as_status=$?; test $as_status -eq 0 && as_status=1
366 if test "$3"; then
367 as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
368 $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
369 fi
370 $as_echo "$as_me: error: $1" >&2
371 as_fn_exit $as_status
372 } # as_fn_error
373
374 if expr a : '\(a\)' >/dev/null 2>&1 &&
375 test "X`expr 00001 : '.*\(...\)'`" = X001; then
376 as_expr=expr
377 else
378 as_expr=false
379 fi
380
381 if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
382 as_basename=basename
383 else
384 as_basename=false
385 fi
386
387 if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
388 as_dirname=dirname
389 else
390 as_dirname=false
391 fi
392
393 as_me=`$as_basename -- "$0" ||
394 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
395 X"$0" : 'X\(//\)$' \| \
396 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
397 $as_echo X/"$0" |
398 sed '/^.*\/\([^/][^/]*\)\/*$/{
399 s//\1/
400 q
401 }
402 /^X\/\(\/\/\)$/{
403 s//\1/
404 q
405 }
406 /^X\/\(\/\).*/{
407 s//\1/
408 q
409 }
410 s/.*/./; q'`
411
412 # Avoid depending upon Character Ranges.
413 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
414 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
415 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
416 as_cr_digits='0123456789'
417 as_cr_alnum=$as_cr_Letters$as_cr_digits
418
419
420 as_lineno_1=$LINENO as_lineno_1a=$LINENO
421 as_lineno_2=$LINENO as_lineno_2a=$LINENO
422 eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
423 test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
424 # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
425 sed -n '
426 p
427 /[$]LINENO/=
428 ' <$as_myself |
429 sed '
430 s/[$]LINENO.*/&-/
431 t lineno
432 b
433 :lineno
434 N
435 :loop
436 s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
437 t loop
438 s/-\n.*//
439 ' >$as_me.lineno &&
440 chmod +x "$as_me.lineno" ||
441 { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
442
443 # Don't try to exec as it changes $[0], causing all sort of problems
444 # (the dirname of $[0] is not the place where we might find the
445 # original and so on. Autoconf is especially sensitive to this).
446 . "./$as_me.lineno"
447 # Exit status is that of the last command.
448 exit
449 }
450
451 ECHO_C= ECHO_N= ECHO_T=
452 case `echo -n x` in #(((((
453 -n*)
454 case `echo 'xy\c'` in
455 *c*) ECHO_T=' ';; # ECHO_T is single tab character.
456 xy) ECHO_C='\c';;
457 *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
458 ECHO_T=' ';;
459 esac;;
460 *)
461 ECHO_N='-n';;
462 esac
463
464 rm -f conf$$ conf$$.exe conf$$.file
465 if test -d conf$$.dir; then
466 rm -f conf$$.dir/conf$$.file
467 else
468 rm -f conf$$.dir
469 mkdir conf$$.dir 2>/dev/null
470 fi
471 if (echo >conf$$.file) 2>/dev/null; then
472 if ln -s conf$$.file conf$$ 2>/dev/null; then
473 as_ln_s='ln -s'
474 # ... but there are two gotchas:
475 # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
476 # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
477 # In both cases, we have to default to `cp -p'.
478 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
479 as_ln_s='cp -p'
480 elif ln conf$$.file conf$$ 2>/dev/null; then
481 as_ln_s=ln
482 else
483 as_ln_s='cp -p'
484 fi
485 else
486 as_ln_s='cp -p'
487 fi
488 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
489 rmdir conf$$.dir 2>/dev/null
490
491 if mkdir -p . 2>/dev/null; then
492 as_mkdir_p='mkdir -p "$as_dir"'
493 else
494 test -d ./-p && rmdir ./-p
495 as_mkdir_p=false
496 fi
497
498 if test -x / >/dev/null 2>&1; then
499 as_test_x='test -x'
500 else
501 if ls -dL / >/dev/null 2>&1; then
502 as_ls_L_option=L
503 else
504 as_ls_L_option=
505 fi
506 as_test_x='
507 eval sh -c '\''
508 if test -d "$1"; then
509 test -d "$1/.";
510 else
511 case $1 in #(
512 -*)set "./$1";;
513 esac;
514 case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
515 ???[sx]*):;;*)false;;esac;fi
516 '\'' sh
517 '
518 fi
519 as_executable_p=$as_test_x
520
521 # Sed expression to map a string onto a valid CPP name.
522 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
523
524 # Sed expression to map a string onto a valid variable name.
525 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
526
527
528 test -n "$DJDIR" || exec 7<&0 </dev/null
529 exec 6>&1
530
531 # Name of the host.
532 # hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
533 # so uname gets run too.
534 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
535
536 #
537 # Initializations.
538 #
539 ac_default_prefix=/usr/local
540 ac_clean_files=
541 ac_config_libobj_dir=.
542 LIBOBJS=
543 cross_compiling=no
544 subdirs=
545 MFLAGS=
546 MAKEFLAGS=
547
548 # Identity of this package.
549 PACKAGE_NAME=
550 PACKAGE_TARNAME=
551 PACKAGE_VERSION=
552 PACKAGE_STRING=
553 PACKAGE_BUGREPORT=
554 PACKAGE_URL=
555
556 ac_unique_file="README"
557 ac_unique_file="job.c"
558 # Factoring default headers for most tests.
559 ac_includes_default="\
560 #include <stdio.h>
561 #ifdef HAVE_SYS_TYPES_H
562 # include <sys/types.h>
563 #endif
564 #ifdef HAVE_SYS_STAT_H
565 # include <sys/stat.h>
566 #endif
567 #ifdef STDC_HEADERS
568 # include <stdlib.h>
569 # include <stddef.h>
570 #else
571 # ifdef HAVE_STDLIB_H
572 # include <stdlib.h>
573 # endif
574 #endif
575 #ifdef HAVE_STRING_H
576 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
577 # include <memory.h>
578 # endif
579 # include <string.h>
580 #endif
581 #ifdef HAVE_STRINGS_H
582 # include <strings.h>
583 #endif
584 #ifdef HAVE_INTTYPES_H
585 # include <inttypes.h>
586 #endif
587 #ifdef HAVE_STDINT_H
588 # include <stdint.h>
589 #endif
590 #ifdef HAVE_UNISTD_H
591 # include <unistd.h>
592 #endif"
593
594 ac_subst_vars='am__EXEEXT_FALSE
595 am__EXEEXT_TRUE
596 LTLIBOBJS
597 LIBOBJS
598 INSTALL_STRIP_FLAG
599 EGREP
600 GREP
601 CPP
602 am__fastdepCC_FALSE
603 am__fastdepCC_TRUE
604 CCDEPMODE
605 AMDEPBACKSLASH
606 AMDEP_FALSE
607 AMDEP_TRUE
608 am__quote
609 am__include
610 DEPDIR
611 OBJEXT
612 EXEEXT
613 ac_ct_CC
614 CPPFLAGS
615 LDFLAGS
616 CFLAGS
617 CC
618 MAINT
619 MAINTAINER_MODE_FALSE
620 MAINTAINER_MODE_TRUE
621 am__untar
622 am__tar
623 AMTAR
624 am__leading_dot
625 SET_MAKE
626 AWK
627 mkdir_p
628 MKDIR_P
629 INSTALL_STRIP_PROGRAM
630 STRIP
631 install_sh
632 MAKEINFO
633 AUTOHEADER
634 AUTOMAKE
635 AUTOCONF
636 ACLOCAL
637 VERSION
638 PACKAGE
639 CYGPATH_W
640 am__isrc
641 INSTALL_DATA
642 INSTALL_SCRIPT
643 INSTALL_PROGRAM
644 target_alias
645 host_alias
646 build_alias
647 LIBS
648 ECHO_T
649 ECHO_N
650 ECHO_C
651 DEFS
652 mandir
653 localedir
654 libdir
655 psdir
656 pdfdir
657 dvidir
658 htmldir
659 infodir
660 docdir
661 oldincludedir
662 includedir
663 localstatedir
664 sharedstatedir
665 sysconfdir
666 datadir
667 datarootdir
668 libexecdir
669 sbindir
670 bindir
671 program_transform_name
672 prefix
673 exec_prefix
674 PACKAGE_URL
675 PACKAGE_BUGREPORT
676 PACKAGE_STRING
677 PACKAGE_VERSION
678 PACKAGE_TARNAME
679 PACKAGE_NAME
680 PATH_SEPARATOR
681 SHELL'
682 ac_subst_files=''
683 ac_user_opts='
684 enable_option_checking
685 enable_maintainer_mode
686 enable_dependency_tracking
687 with_libdir
688 enable_rpath
689 with_event
690 enable_debug
691 '
692 ac_precious_vars='build_alias
693 host_alias
694 target_alias
695 CC
696 CFLAGS
697 LDFLAGS
698 LIBS
699 CPPFLAGS
700 CPP'
701
702
703 # Initialize some variables set by options.
704 ac_init_help=
705 ac_init_version=false
706 ac_unrecognized_opts=
707 ac_unrecognized_sep=
708 # The variables have the same names as the options, with
709 # dashes changed to underlines.
710 cache_file=/dev/null
711 exec_prefix=NONE
712 no_create=
713 no_recursion=
714 prefix=NONE
715 program_prefix=NONE
716 program_suffix=NONE
717 program_transform_name=s,x,x,
718 silent=
719 site=
720 srcdir=
721 verbose=
722 x_includes=NONE
723 x_libraries=NONE
724
725 # Installation directory options.
726 # These are left unexpanded so users can "make install exec_prefix=/foo"
727 # and all the variables that are supposed to be based on exec_prefix
728 # by default will actually change.
729 # Use braces instead of parens because sh, perl, etc. also accept them.
730 # (The list follows the same order as the GNU Coding Standards.)
731 bindir='${exec_prefix}/bin'
732 sbindir='${exec_prefix}/sbin'
733 libexecdir='${exec_prefix}/libexec'
734 datarootdir='${prefix}/share'
735 datadir='${datarootdir}'
736 sysconfdir='${prefix}/etc'
737 sharedstatedir='${prefix}/com'
738 localstatedir='${prefix}/var'
739 includedir='${prefix}/include'
740 oldincludedir='/usr/include'
741 docdir='${datarootdir}/doc/${PACKAGE}'
742 infodir='${datarootdir}/info'
743 htmldir='${docdir}'
744 dvidir='${docdir}'
745 pdfdir='${docdir}'
746 psdir='${docdir}'
747 libdir='${exec_prefix}/lib'
748 localedir='${datarootdir}/locale'
749 mandir='${datarootdir}/man'
750
751 ac_prev=
752 ac_dashdash=
753 for ac_option
754 do
755 # If the previous option needs an argument, assign it.
756 if test -n "$ac_prev"; then
757 eval $ac_prev=\$ac_option
758 ac_prev=
759 continue
760 fi
761
762 case $ac_option in
763 *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
764 *) ac_optarg=yes ;;
765 esac
766
767 # Accept the important Cygnus configure options, so we can diagnose typos.
768
769 case $ac_dashdash$ac_option in
770 --)
771 ac_dashdash=yes ;;
772
773 -bindir | --bindir | --bindi | --bind | --bin | --bi)
774 ac_prev=bindir ;;
775 -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
776 bindir=$ac_optarg ;;
777
778 -build | --build | --buil | --bui | --bu)
779 ac_prev=build_alias ;;
780 -build=* | --build=* | --buil=* | --bui=* | --bu=*)
781 build_alias=$ac_optarg ;;
782
783 -cache-file | --cache-file | --cache-fil | --cache-fi \
784 | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
785 ac_prev=cache_file ;;
786 -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
787 | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
788 cache_file=$ac_optarg ;;
789
790 --config-cache | -C)
791 cache_file=config.cache ;;
792
793 -datadir | --datadir | --datadi | --datad)
794 ac_prev=datadir ;;
795 -datadir=* | --datadir=* | --datadi=* | --datad=*)
796 datadir=$ac_optarg ;;
797
798 -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
799 | --dataroo | --dataro | --datar)
800 ac_prev=datarootdir ;;
801 -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
802 | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
803 datarootdir=$ac_optarg ;;
804
805 -disable-* | --disable-*)
806 ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
807 # Reject names that are not valid shell variable names.
808 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
809 as_fn_error "invalid feature name: $ac_useropt"
810 ac_useropt_orig=$ac_useropt
811 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
812 case $ac_user_opts in
813 *"
814 "enable_$ac_useropt"
815 "*) ;;
816 *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
817 ac_unrecognized_sep=', ';;
818 esac
819 eval enable_$ac_useropt=no ;;
820
821 -docdir | --docdir | --docdi | --doc | --do)
822 ac_prev=docdir ;;
823 -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
824 docdir=$ac_optarg ;;
825
826 -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
827 ac_prev=dvidir ;;
828 -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
829 dvidir=$ac_optarg ;;
830
831 -enable-* | --enable-*)
832 ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
833 # Reject names that are not valid shell variable names.
834 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
835 as_fn_error "invalid feature name: $ac_useropt"
836 ac_useropt_orig=$ac_useropt
837 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
838 case $ac_user_opts in
839 *"
840 "enable_$ac_useropt"
841 "*) ;;
842 *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
843 ac_unrecognized_sep=', ';;
844 esac
845 eval enable_$ac_useropt=\$ac_optarg ;;
846
847 -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
848 | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
849 | --exec | --exe | --ex)
850 ac_prev=exec_prefix ;;
851 -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
852 | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
853 | --exec=* | --exe=* | --ex=*)
854 exec_prefix=$ac_optarg ;;
855
856 -gas | --gas | --ga | --g)
857 # Obsolete; use --with-gas.
858 with_gas=yes ;;
859
860 -help | --help | --hel | --he | -h)
861 ac_init_help=long ;;
862 -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
863 ac_init_help=recursive ;;
864 -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
865 ac_init_help=short ;;
866
867 -host | --host | --hos | --ho)
868 ac_prev=host_alias ;;
869 -host=* | --host=* | --hos=* | --ho=*)
870 host_alias=$ac_optarg ;;
871
872 -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
873 ac_prev=htmldir ;;
874 -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
875 | --ht=*)
876 htmldir=$ac_optarg ;;
877
878 -includedir | --includedir | --includedi | --included | --include \
879 | --includ | --inclu | --incl | --inc)
880 ac_prev=includedir ;;
881 -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
882 | --includ=* | --inclu=* | --incl=* | --inc=*)
883 includedir=$ac_optarg ;;
884
885 -infodir | --infodir | --infodi | --infod | --info | --inf)
886 ac_prev=infodir ;;
887 -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
888 infodir=$ac_optarg ;;
889
890 -libdir | --libdir | --libdi | --libd)
891 ac_prev=libdir ;;
892 -libdir=* | --libdir=* | --libdi=* | --libd=*)
893 libdir=$ac_optarg ;;
894
895 -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
896 | --libexe | --libex | --libe)
897 ac_prev=libexecdir ;;
898 -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
899 | --libexe=* | --libex=* | --libe=*)
900 libexecdir=$ac_optarg ;;
901
902 -localedir | --localedir | --localedi | --localed | --locale)
903 ac_prev=localedir ;;
904 -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
905 localedir=$ac_optarg ;;
906
907 -localstatedir | --localstatedir | --localstatedi | --localstated \
908 | --localstate | --localstat | --localsta | --localst | --locals)
909 ac_prev=localstatedir ;;
910 -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
911 | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
912 localstatedir=$ac_optarg ;;
913
914 -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
915 ac_prev=mandir ;;
916 -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
917 mandir=$ac_optarg ;;
918
919 -nfp | --nfp | --nf)
920 # Obsolete; use --without-fp.
921 with_fp=no ;;
922
923 -no-create | --no-create | --no-creat | --no-crea | --no-cre \
924 | --no-cr | --no-c | -n)
925 no_create=yes ;;
926
927 -no-recursion | --no-recursion | --no-recursio | --no-recursi \
928 | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
929 no_recursion=yes ;;
930
931 -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
932 | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
933 | --oldin | --oldi | --old | --ol | --o)
934 ac_prev=oldincludedir ;;
935 -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
936 | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
937 | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
938 oldincludedir=$ac_optarg ;;
939
940 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
941 ac_prev=prefix ;;
942 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
943 prefix=$ac_optarg ;;
944
945 -program-prefix | --program-prefix | --program-prefi | --program-pref \
946 | --program-pre | --program-pr | --program-p)
947 ac_prev=program_prefix ;;
948 -program-prefix=* | --program-prefix=* | --program-prefi=* \
949 | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
950 program_prefix=$ac_optarg ;;
951
952 -program-suffix | --program-suffix | --program-suffi | --program-suff \
953 | --program-suf | --program-su | --program-s)
954 ac_prev=program_suffix ;;
955 -program-suffix=* | --program-suffix=* | --program-suffi=* \
956 | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
957 program_suffix=$ac_optarg ;;
958
959 -program-transform-name | --program-transform-name \
960 | --program-transform-nam | --program-transform-na \
961 | --program-transform-n | --program-transform- \
962 | --program-transform | --program-transfor \
963 | --program-transfo | --program-transf \
964 | --program-trans | --program-tran \
965 | --progr-tra | --program-tr | --program-t)
966 ac_prev=program_transform_name ;;
967 -program-transform-name=* | --program-transform-name=* \
968 | --program-transform-nam=* | --program-transform-na=* \
969 | --program-transform-n=* | --program-transform-=* \
970 | --program-transform=* | --program-transfor=* \
971 | --program-transfo=* | --program-transf=* \
972 | --program-trans=* | --program-tran=* \
973 | --progr-tra=* | --program-tr=* | --program-t=*)
974 program_transform_name=$ac_optarg ;;
975
976 -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
977 ac_prev=pdfdir ;;
978 -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
979 pdfdir=$ac_optarg ;;
980
981 -psdir | --psdir | --psdi | --psd | --ps)
982 ac_prev=psdir ;;
983 -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
984 psdir=$ac_optarg ;;
985
986 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
987 | -silent | --silent | --silen | --sile | --sil)
988 silent=yes ;;
989
990 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
991 ac_prev=sbindir ;;
992 -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
993 | --sbi=* | --sb=*)
994 sbindir=$ac_optarg ;;
995
996 -sharedstatedir | --sharedstatedir | --sharedstatedi \
997 | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
998 | --sharedst | --shareds | --shared | --share | --shar \
999 | --sha | --sh)
1000 ac_prev=sharedstatedir ;;
1001 -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
1002 | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
1003 | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
1004 | --sha=* | --sh=*)
1005 sharedstatedir=$ac_optarg ;;
1006
1007 -site | --site | --sit)
1008 ac_prev=site ;;
1009 -site=* | --site=* | --sit=*)
1010 site=$ac_optarg ;;
1011
1012 -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
1013 ac_prev=srcdir ;;
1014 -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
1015 srcdir=$ac_optarg ;;
1016
1017 -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
1018 | --syscon | --sysco | --sysc | --sys | --sy)
1019 ac_prev=sysconfdir ;;
1020 -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
1021 | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
1022 sysconfdir=$ac_optarg ;;
1023
1024 -target | --target | --targe | --targ | --tar | --ta | --t)
1025 ac_prev=target_alias ;;
1026 -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
1027 target_alias=$ac_optarg ;;
1028
1029 -v | -verbose | --verbose | --verbos | --verbo | --verb)
1030 verbose=yes ;;
1031
1032 -version | --version | --versio | --versi | --vers | -V)
1033 ac_init_version=: ;;
1034
1035 -with-* | --with-*)
1036 ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
1037 # Reject names that are not valid shell variable names.
1038 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
1039 as_fn_error "invalid package name: $ac_useropt"
1040 ac_useropt_orig=$ac_useropt
1041 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
1042 case $ac_user_opts in
1043 *"
1044 "with_$ac_useropt"
1045 "*) ;;
1046 *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
1047 ac_unrecognized_sep=', ';;
1048 esac
1049 eval with_$ac_useropt=\$ac_optarg ;;
1050
1051 -without-* | --without-*)
1052 ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
1053 # Reject names that are not valid shell variable names.
1054 expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
1055 as_fn_error "invalid package name: $ac_useropt"
1056 ac_useropt_orig=$ac_useropt
1057 ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
1058 case $ac_user_opts in
1059 *"
1060 "with_$ac_useropt"
1061 "*) ;;
1062 *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
1063 ac_unrecognized_sep=', ';;
1064 esac
1065 eval with_$ac_useropt=no ;;
1066
1067 --x)
1068 # Obsolete; use --with-x.
1069 with_x=yes ;;
1070
1071 -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
1072 | --x-incl | --x-inc | --x-in | --x-i)
1073 ac_prev=x_includes ;;
1074 -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
1075 | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
1076 x_includes=$ac_optarg ;;
1077
1078 -x-libraries | --x-libraries | --x-librarie | --x-librari \
1079 | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
1080 ac_prev=x_libraries ;;
1081 -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
1082 | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
1083 x_libraries=$ac_optarg ;;
1084
1085 -*) as_fn_error "unrecognized option: \`$ac_option'
1086 Try \`$0 --help' for more information."
1087 ;;
1088
1089 *=*)
1090 ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
1091 # Reject names that are not valid shell variable names.
1092 case $ac_envvar in #(
1093 '' | [0-9]* | *[!_$as_cr_alnum]* )
1094 as_fn_error "invalid variable name: \`$ac_envvar'" ;;
1095 esac
1096 eval $ac_envvar=\$ac_optarg
1097 export $ac_envvar ;;
1098
1099 *)
1100 # FIXME: should be removed in autoconf 3.0.
1101 $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
1102 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
1103 $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
1104 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
1105 ;;
1106
1107 esac
1108 done
1109
1110 if test -n "$ac_prev"; then
1111 ac_option=--`echo $ac_prev | sed 's/_/-/g'`
1112 as_fn_error "missing argument to $ac_option"
1113 fi
1114
1115 if test -n "$ac_unrecognized_opts"; then
1116 case $enable_option_checking in
1117 no) ;;
1118 fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
1119 *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
1120 esac
1121 fi
1122
1123 # Check all directory arguments for consistency.
1124 for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
1125 datadir sysconfdir sharedstatedir localstatedir includedir \
1126 oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
1127 libdir localedir mandir
1128 do
1129 eval ac_val=\$$ac_var
1130 # Remove trailing slashes.
1131 case $ac_val in
1132 */ )
1133 ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
1134 eval $ac_var=\$ac_val;;
1135 esac
1136 # Be sure to have absolute directory names.
1137 case $ac_val in
1138 [\\/$]* | ?:[\\/]* ) continue;;
1139 NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
1140 esac
1141 as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
1142 done
1143
1144 # There might be people who depend on the old broken behavior: `$host'
1145 # used to hold the argument of --host etc.
1146 # FIXME: To remove some day.
1147 build=$build_alias
1148 host=$host_alias
1149 target=$target_alias
1150
1151 # FIXME: To remove some day.
1152 if test "x$host_alias" != x; then
1153 if test "x$build_alias" = x; then
1154 cross_compiling=maybe
1155 $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
1156 If a cross compiler is detected then cross compile mode will be used." >&2
1157 elif test "x$build_alias" != "x$host_alias"; then
1158 cross_compiling=yes
1159 fi
1160 fi
1161
1162 ac_tool_prefix=
1163 test -n "$host_alias" && ac_tool_prefix=$host_alias-
1164
1165 test "$silent" = yes && exec 6>/dev/null
1166
1167
1168 ac_pwd=`pwd` && test -n "$ac_pwd" &&
1169 ac_ls_di=`ls -di .` &&
1170 ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
1171 as_fn_error "working directory cannot be determined"
1172 test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
1173 as_fn_error "pwd does not report name of working directory"
1174
1175
1176 # Find the source files, if location was not specified.
1177 if test -z "$srcdir"; then
1178 ac_srcdir_defaulted=yes
1179 # Try the directory containing this script, then the parent directory.
1180 ac_confdir=`$as_dirname -- "$as_myself" ||
1181 $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
1182 X"$as_myself" : 'X\(//\)[^/]' \| \
1183 X"$as_myself" : 'X\(//\)$' \| \
1184 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
1185 $as_echo X"$as_myself" |
1186 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
1187 s//\1/
1188 q
1189 }
1190 /^X\(\/\/\)[^/].*/{
1191 s//\1/
1192 q
1193 }
1194 /^X\(\/\/\)$/{
1195 s//\1/
1196 q
1197 }
1198 /^X\(\/\).*/{
1199 s//\1/
1200 q
1201 }
1202 s/.*/./; q'`
1203 srcdir=$ac_confdir
1204 if test ! -r "$srcdir/$ac_unique_file"; then
1205 srcdir=..
1206 fi
1207 else
1208 ac_srcdir_defaulted=no
1209 fi
1210 if test ! -r "$srcdir/$ac_unique_file"; then
1211 test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
1212 as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
1213 fi
1214 ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
1215 ac_abs_confdir=`(
1216 cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
1217 pwd)`
1218 # When building in place, set srcdir=.
1219 if test "$ac_abs_confdir" = "$ac_pwd"; then
1220 srcdir=.
1221 fi
1222 # Remove unnecessary trailing slashes from srcdir.
1223 # Double slashes in file names in object file debugging info
1224 # mess up M-x gdb in Emacs.
1225 case $srcdir in
1226 */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
1227 esac
1228 for ac_var in $ac_precious_vars; do
1229 eval ac_env_${ac_var}_set=\${${ac_var}+set}
1230 eval ac_env_${ac_var}_value=\$${ac_var}
1231 eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
1232 eval ac_cv_env_${ac_var}_value=\$${ac_var}
1233 done
1234
1235 #
1236 # Report the --help message.
1237 #
1238 if test "$ac_init_help" = "long"; then
1239 # Omit some internal or obsolete options to make the list less imposing.
1240 # This message is too long to be a string in the A/UX 3.1 sh.
1241 cat <<_ACEOF
1242 \`configure' configures this package to adapt to many kinds of systems.
1243
1244 Usage: $0 [OPTION]... [VAR=VALUE]...
1245
1246 To assign environment variables (e.g., CC, CFLAGS...), specify them as
1247 VAR=VALUE. See below for descriptions of some of the useful variables.
1248
1249 Defaults for the options are specified in brackets.
1250
1251 Configuration:
1252 -h, --help display this help and exit
1253 --help=short display options specific to this package
1254 --help=recursive display the short help of all the included packages
1255 -V, --version display version information and exit
1256 -q, --quiet, --silent do not print \`checking...' messages
1257 --cache-file=FILE cache test results in FILE [disabled]
1258 -C, --config-cache alias for \`--cache-file=config.cache'
1259 -n, --no-create do not create output files
1260 --srcdir=DIR find the sources in DIR [configure dir or \`..']
1261
1262 Installation directories:
1263 --prefix=PREFIX install architecture-independent files in PREFIX
1264 [$ac_default_prefix]
1265 --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
1266 [PREFIX]
1267
1268 By default, \`make install' will install all the files in
1269 \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
1270 an installation prefix other than \`$ac_default_prefix' using \`--prefix',
1271 for instance \`--prefix=\$HOME'.
1272
1273 For better control, use the options below.
1274
1275 Fine tuning of the installation directories:
1276 --bindir=DIR user executables [EPREFIX/bin]
1277 --sbindir=DIR system admin executables [EPREFIX/sbin]
1278 --libexecdir=DIR program executables [EPREFIX/libexec]
1279 --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
1280 --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
1281 --localstatedir=DIR modifiable single-machine data [PREFIX/var]
1282 --libdir=DIR object code libraries [EPREFIX/lib]
1283 --includedir=DIR C header files [PREFIX/include]
1284 --oldincludedir=DIR C header files for non-gcc [/usr/include]
1285 --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
1286 --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
1287 --infodir=DIR info documentation [DATAROOTDIR/info]
1288 --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
1289 --mandir=DIR man documentation [DATAROOTDIR/man]
1290 --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
1291 --htmldir=DIR html documentation [DOCDIR]
1292 --dvidir=DIR dvi documentation [DOCDIR]
1293 --pdfdir=DIR pdf documentation [DOCDIR]
1294 --psdir=DIR ps documentation [DOCDIR]
1295 _ACEOF
1296
1297 cat <<\_ACEOF
1298
1299 Program names:
1300 --program-prefix=PREFIX prepend PREFIX to installed program names
1301 --program-suffix=SUFFIX append SUFFIX to installed program names
1302 --program-transform-name=PROGRAM run sed PROGRAM on installed program names
1303 _ACEOF
1304 fi
1305
1306 if test -n "$ac_init_help"; then
1307
1308 cat <<\_ACEOF
1309
1310 Optional Features:
1311 --disable-option-checking ignore unrecognized --enable/--with options
1312 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
1313 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
1314 --enable-maintainer-mode enable make rules and dependencies not useful
1315 (and sometimes confusing) to the casual installer
1316 --disable-dependency-tracking speeds up one-time build
1317 --enable-dependency-tracking do not reject slow dependency extractors
1318 --disable-rpath disable passing additional runtime library search
1319 paths
1320
1321 --enable-debug enable debugging symbols and compile flags
1322
1323
1324 Optional Packages:
1325 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
1326 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
1327 --with-libdir look for libraries in .../NAME rather than .../lib
1328
1329 --with-event specify libevent install prefix
1330
1331
1332 Some influential environment variables:
1333 CC C compiler command
1334 CFLAGS C compiler flags
1335 LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
1336 nonstandard directory <lib dir>
1337 LIBS libraries to pass to the linker, e.g. -l<library>
1338 CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
1339 you have headers in a nonstandard directory <include dir>
1340 CPP C preprocessor
1341
1342 Use these variables to override the choices made by `configure' or to help
1343 it to find libraries and programs with nonstandard names/locations.
1344
1345 Report bugs to the package provider.
1346 _ACEOF
1347 ac_status=$?
1348 fi
1349
1350 if test "$ac_init_help" = "recursive"; then
1351 # If there are subdirs, report their specific --help.
1352 for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
1353 test -d "$ac_dir" ||
1354 { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
1355 continue
1356 ac_builddir=.
1357
1358 case "$ac_dir" in
1359 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
1360 *)
1361 ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
1362 # A ".." for each directory in $ac_dir_suffix.
1363 ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
1364 case $ac_top_builddir_sub in
1365 "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
1366 *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
1367 esac ;;
1368 esac
1369 ac_abs_top_builddir=$ac_pwd
1370 ac_abs_builddir=$ac_pwd$ac_dir_suffix
1371 # for backward compatibility:
1372 ac_top_builddir=$ac_top_build_prefix
1373
1374 case $srcdir in
1375 .) # We are building in place.
1376 ac_srcdir=.
1377 ac_top_srcdir=$ac_top_builddir_sub
1378 ac_abs_top_srcdir=$ac_pwd ;;
1379 [\\/]* | ?:[\\/]* ) # Absolute name.
1380 ac_srcdir=$srcdir$ac_dir_suffix;
1381 ac_top_srcdir=$srcdir
1382 ac_abs_top_srcdir=$srcdir ;;
1383 *) # Relative name.
1384 ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
1385 ac_top_srcdir=$ac_top_build_prefix$srcdir
1386 ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
1387 esac
1388 ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
1389
1390 cd "$ac_dir" || { ac_status=$?; continue; }
1391 # Check for guested configure.
1392 if test -f "$ac_srcdir/configure.gnu"; then
1393 echo &&
1394 $SHELL "$ac_srcdir/configure.gnu" --help=recursive
1395 elif test -f "$ac_srcdir/configure"; then
1396 echo &&
1397 $SHELL "$ac_srcdir/configure" --help=recursive
1398 else
1399 $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
1400 fi || ac_status=$?
1401 cd "$ac_pwd" || { ac_status=$?; break; }
1402 done
1403 fi
1404
1405 test -n "$ac_init_help" && exit $ac_status
1406 if $ac_init_version; then
1407 cat <<\_ACEOF
1408 configure
1409 generated by GNU Autoconf 2.65
1410
1411 Copyright (C) 2009 Free Software Foundation, Inc.
1412 This configure script is free software; the Free Software Foundation
1413 gives unlimited permission to copy, distribute and modify it.
1414 _ACEOF
1415 exit
1416 fi
1417
1418 ## ------------------------ ##
1419 ## Autoconf initialization. ##
1420 ## ------------------------ ##
1421
1422 # ac_fn_c_try_compile LINENO
1423 # --------------------------
1424 # Try to compile conftest.$ac_ext, and return whether this succeeded.
1425 ac_fn_c_try_compile ()
1426 {
1427 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1428 rm -f conftest.$ac_objext
1429 if { { ac_try="$ac_compile"
1430 case "(($ac_try" in
1431 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1432 *) ac_try_echo=$ac_try;;
1433 esac
1434 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1435 $as_echo "$ac_try_echo"; } >&5
1436 (eval "$ac_compile") 2>conftest.err
1437 ac_status=$?
1438 if test -s conftest.err; then
1439 grep -v '^ *+' conftest.err >conftest.er1
1440 cat conftest.er1 >&5
1441 mv -f conftest.er1 conftest.err
1442 fi
1443 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1444 test $ac_status = 0; } && {
1445 test -z "$ac_c_werror_flag" ||
1446 test ! -s conftest.err
1447 } && test -s conftest.$ac_objext; then :
1448 ac_retval=0
1449 else
1450 $as_echo "$as_me: failed program was:" >&5
1451 sed 's/^/| /' conftest.$ac_ext >&5
1452
1453 ac_retval=1
1454 fi
1455 eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
1456 as_fn_set_status $ac_retval
1457
1458 } # ac_fn_c_try_compile
1459
1460 # ac_fn_c_try_link LINENO
1461 # -----------------------
1462 # Try to link conftest.$ac_ext, and return whether this succeeded.
1463 ac_fn_c_try_link ()
1464 {
1465 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1466 rm -f conftest.$ac_objext conftest$ac_exeext
1467 if { { ac_try="$ac_link"
1468 case "(($ac_try" in
1469 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1470 *) ac_try_echo=$ac_try;;
1471 esac
1472 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1473 $as_echo "$ac_try_echo"; } >&5
1474 (eval "$ac_link") 2>conftest.err
1475 ac_status=$?
1476 if test -s conftest.err; then
1477 grep -v '^ *+' conftest.err >conftest.er1
1478 cat conftest.er1 >&5
1479 mv -f conftest.er1 conftest.err
1480 fi
1481 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1482 test $ac_status = 0; } && {
1483 test -z "$ac_c_werror_flag" ||
1484 test ! -s conftest.err
1485 } && test -s conftest$ac_exeext && {
1486 test "$cross_compiling" = yes ||
1487 $as_test_x conftest$ac_exeext
1488 }; then :
1489 ac_retval=0
1490 else
1491 $as_echo "$as_me: failed program was:" >&5
1492 sed 's/^/| /' conftest.$ac_ext >&5
1493
1494 ac_retval=1
1495 fi
1496 # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
1497 # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
1498 # interfere with the next link command; also delete a directory that is
1499 # left behind by Apple's compiler. We do this before executing the actions.
1500 rm -rf conftest.dSYM conftest_ipa8_conftest.oo
1501 eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
1502 as_fn_set_status $ac_retval
1503
1504 } # ac_fn_c_try_link
1505
1506 # ac_fn_c_check_func LINENO FUNC VAR
1507 # ----------------------------------
1508 # Tests whether FUNC exists, setting the cache variable VAR accordingly
1509 ac_fn_c_check_func ()
1510 {
1511 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1512 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
1513 $as_echo_n "checking for $2... " >&6; }
1514 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
1515 $as_echo_n "(cached) " >&6
1516 else
1517 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1518 /* end confdefs.h. */
1519 /* Define $2 to an innocuous variant, in case <limits.h> declares $2.
1520 For example, HP-UX 11i <limits.h> declares gettimeofday. */
1521 #define $2 innocuous_$2
1522
1523 /* System header to define __stub macros and hopefully few prototypes,
1524 which can conflict with char $2 (); below.
1525 Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
1526 <limits.h> exists even on freestanding compilers. */
1527
1528 #ifdef __STDC__
1529 # include <limits.h>
1530 #else
1531 # include <assert.h>
1532 #endif
1533
1534 #undef $2
1535
1536 /* Override any GCC internal prototype to avoid an error.
1537 Use char because int might match the return type of a GCC
1538 builtin and then its argument prototype would still apply. */
1539 #ifdef __cplusplus
1540 extern "C"
1541 #endif
1542 char $2 ();
1543 /* The GNU C library defines this for functions which it implements
1544 to always fail with ENOSYS. Some functions are actually named
1545 something starting with __ and the normal name is an alias. */
1546 #if defined __stub_$2 || defined __stub___$2
1547 choke me
1548 #endif
1549
1550 int
1551 main ()
1552 {
1553 return $2 ();
1554 ;
1555 return 0;
1556 }
1557 _ACEOF
1558 if ac_fn_c_try_link "$LINENO"; then :
1559 eval "$3=yes"
1560 else
1561 eval "$3=no"
1562 fi
1563 rm -f core conftest.err conftest.$ac_objext \
1564 conftest$ac_exeext conftest.$ac_ext
1565 fi
1566 eval ac_res=\$$3
1567 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1568 $as_echo "$ac_res" >&6; }
1569 eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
1570
1571 } # ac_fn_c_check_func
1572
1573 # ac_fn_c_try_cpp LINENO
1574 # ----------------------
1575 # Try to preprocess conftest.$ac_ext, and return whether this succeeded.
1576 ac_fn_c_try_cpp ()
1577 {
1578 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1579 if { { ac_try="$ac_cpp conftest.$ac_ext"
1580 case "(($ac_try" in
1581 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1582 *) ac_try_echo=$ac_try;;
1583 esac
1584 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1585 $as_echo "$ac_try_echo"; } >&5
1586 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
1587 ac_status=$?
1588 if test -s conftest.err; then
1589 grep -v '^ *+' conftest.err >conftest.er1
1590 cat conftest.er1 >&5
1591 mv -f conftest.er1 conftest.err
1592 fi
1593 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1594 test $ac_status = 0; } >/dev/null && {
1595 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
1596 test ! -s conftest.err
1597 }; then :
1598 ac_retval=0
1599 else
1600 $as_echo "$as_me: failed program was:" >&5
1601 sed 's/^/| /' conftest.$ac_ext >&5
1602
1603 ac_retval=1
1604 fi
1605 eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
1606 as_fn_set_status $ac_retval
1607
1608 } # ac_fn_c_try_cpp
1609
1610 # ac_fn_c_try_run LINENO
1611 # ----------------------
1612 # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
1613 # that executables *can* be run.
1614 ac_fn_c_try_run ()
1615 {
1616 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1617 if { { ac_try="$ac_link"
1618 case "(($ac_try" in
1619 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1620 *) ac_try_echo=$ac_try;;
1621 esac
1622 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1623 $as_echo "$ac_try_echo"; } >&5
1624 (eval "$ac_link") 2>&5
1625 ac_status=$?
1626 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1627 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
1628 { { case "(($ac_try" in
1629 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1630 *) ac_try_echo=$ac_try;;
1631 esac
1632 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1633 $as_echo "$ac_try_echo"; } >&5
1634 (eval "$ac_try") 2>&5
1635 ac_status=$?
1636 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1637 test $ac_status = 0; }; }; then :
1638 ac_retval=0
1639 else
1640 $as_echo "$as_me: program exited with status $ac_status" >&5
1641 $as_echo "$as_me: failed program was:" >&5
1642 sed 's/^/| /' conftest.$ac_ext >&5
1643
1644 ac_retval=$ac_status
1645 fi
1646 rm -rf conftest.dSYM conftest_ipa8_conftest.oo
1647 eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
1648 as_fn_set_status $ac_retval
1649
1650 } # ac_fn_c_try_run
1651
1652 # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
1653 # -------------------------------------------------------
1654 # Tests whether HEADER exists and can be compiled using the include files in
1655 # INCLUDES, setting the cache variable VAR accordingly.
1656 ac_fn_c_check_header_compile ()
1657 {
1658 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1659 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
1660 $as_echo_n "checking for $2... " >&6; }
1661 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
1662 $as_echo_n "(cached) " >&6
1663 else
1664 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1665 /* end confdefs.h. */
1666 $4
1667 #include <$2>
1668 _ACEOF
1669 if ac_fn_c_try_compile "$LINENO"; then :
1670 eval "$3=yes"
1671 else
1672 eval "$3=no"
1673 fi
1674 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1675 fi
1676 eval ac_res=\$$3
1677 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1678 $as_echo "$ac_res" >&6; }
1679 eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
1680
1681 } # ac_fn_c_check_header_compile
1682
1683 # ac_fn_c_find_uintX_t LINENO BITS VAR
1684 # ------------------------------------
1685 # Finds an unsigned integer type with width BITS, setting cache variable VAR
1686 # accordingly.
1687 ac_fn_c_find_uintX_t ()
1688 {
1689 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1690 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5
1691 $as_echo_n "checking for uint$2_t... " >&6; }
1692 if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
1693 $as_echo_n "(cached) " >&6
1694 else
1695 eval "$3=no"
1696 # Order is important - never check a type that is potentially smaller
1697 # than half of the expected target width.
1698 for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \
1699 'unsigned long long int' 'unsigned short int' 'unsigned char'; do
1700 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1701 /* end confdefs.h. */
1702 $ac_includes_default
1703 int
1704 main ()
1705 {
1706 static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)];
1707 test_array [0] = 0
1708
1709 ;
1710 return 0;
1711 }
1712 _ACEOF
1713 if ac_fn_c_try_compile "$LINENO"; then :
1714 case $ac_type in #(
1715 uint$2_t) :
1716 eval "$3=yes" ;; #(
1717 *) :
1718 eval "$3=\$ac_type" ;;
1719 esac
1720 fi
1721 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1722 eval as_val=\$$3
1723 if test "x$as_val" = x""no; then :
1724
1725 else
1726 break
1727 fi
1728 done
1729 fi
1730 eval ac_res=\$$3
1731 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
1732 $as_echo "$ac_res" >&6; }
1733 eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
1734
1735 } # ac_fn_c_find_uintX_t
1736 cat >config.log <<_ACEOF
1737 This file contains any messages produced by compilers while
1738 running configure, to aid debugging if configure makes a mistake.
1739
1740 It was created by $as_me, which was
1741 generated by GNU Autoconf 2.65. Invocation command line was
1742
1743 $ $0 $@
1744
1745 _ACEOF
1746 exec 5>>config.log
1747 {
1748 cat <<_ASUNAME
1749 ## --------- ##
1750 ## Platform. ##
1751 ## --------- ##
1752
1753 hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
1754 uname -m = `(uname -m) 2>/dev/null || echo unknown`
1755 uname -r = `(uname -r) 2>/dev/null || echo unknown`
1756 uname -s = `(uname -s) 2>/dev/null || echo unknown`
1757 uname -v = `(uname -v) 2>/dev/null || echo unknown`
1758
1759 /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
1760 /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
1761
1762 /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
1763 /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
1764 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
1765 /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
1766 /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
1767 /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
1768 /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
1769
1770 _ASUNAME
1771
1772 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
1773 for as_dir in $PATH
1774 do
1775 IFS=$as_save_IFS
1776 test -z "$as_dir" && as_dir=.
1777 $as_echo "PATH: $as_dir"
1778 done
1779 IFS=$as_save_IFS
1780
1781 } >&5
1782
1783 cat >&5 <<_ACEOF
1784
1785
1786 ## ----------- ##
1787 ## Core tests. ##
1788 ## ----------- ##
1789
1790 _ACEOF
1791
1792
1793 # Keep a trace of the command line.
1794 # Strip out --no-create and --no-recursion so they do not pile up.
1795 # Strip out --silent because we don't want to record it for future runs.
1796 # Also quote any args containing shell meta-characters.
1797 # Make two passes to allow for proper duplicate-argument suppression.
1798 ac_configure_args=
1799 ac_configure_args0=
1800 ac_configure_args1=
1801 ac_must_keep_next=false
1802 for ac_pass in 1 2
1803 do
1804 for ac_arg
1805 do
1806 case $ac_arg in
1807 -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
1808 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
1809 | -silent | --silent | --silen | --sile | --sil)
1810 continue ;;
1811 *\'*)
1812 ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
1813 esac
1814 case $ac_pass in
1815 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
1816 2)
1817 as_fn_append ac_configure_args1 " '$ac_arg'"
1818 if test $ac_must_keep_next = true; then
1819 ac_must_keep_next=false # Got value, back to normal.
1820 else
1821 case $ac_arg in
1822 *=* | --config-cache | -C | -disable-* | --disable-* \
1823 | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
1824 | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
1825 | -with-* | --with-* | -without-* | --without-* | --x)
1826 case "$ac_configure_args0 " in
1827 "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
1828 esac
1829 ;;
1830 -* ) ac_must_keep_next=true ;;
1831 esac
1832 fi
1833 as_fn_append ac_configure_args " '$ac_arg'"
1834 ;;
1835 esac
1836 done
1837 done
1838 { ac_configure_args0=; unset ac_configure_args0;}
1839 { ac_configure_args1=; unset ac_configure_args1;}
1840
1841 # When interrupted or exit'd, cleanup temporary files, and complete
1842 # config.log. We remove comments because anyway the quotes in there
1843 # would cause problems or look ugly.
1844 # WARNING: Use '\'' to represent an apostrophe within the trap.
1845 # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
1846 trap 'exit_status=$?
1847 # Save into config.log some information that might help in debugging.
1848 {
1849 echo
1850
1851 cat <<\_ASBOX
1852 ## ---------------- ##
1853 ## Cache variables. ##
1854 ## ---------------- ##
1855 _ASBOX
1856 echo
1857 # The following way of writing the cache mishandles newlines in values,
1858 (
1859 for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
1860 eval ac_val=\$$ac_var
1861 case $ac_val in #(
1862 *${as_nl}*)
1863 case $ac_var in #(
1864 *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
1865 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
1866 esac
1867 case $ac_var in #(
1868 _ | IFS | as_nl) ;; #(
1869 BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
1870 *) { eval $ac_var=; unset $ac_var;} ;;
1871 esac ;;
1872 esac
1873 done
1874 (set) 2>&1 |
1875 case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
1876 *${as_nl}ac_space=\ *)
1877 sed -n \
1878 "s/'\''/'\''\\\\'\'''\''/g;
1879 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
1880 ;; #(
1881 *)
1882 sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
1883 ;;
1884 esac |
1885 sort
1886 )
1887 echo
1888
1889 cat <<\_ASBOX
1890 ## ----------------- ##
1891 ## Output variables. ##
1892 ## ----------------- ##
1893 _ASBOX
1894 echo
1895 for ac_var in $ac_subst_vars
1896 do
1897 eval ac_val=\$$ac_var
1898 case $ac_val in
1899 *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
1900 esac
1901 $as_echo "$ac_var='\''$ac_val'\''"
1902 done | sort
1903 echo
1904
1905 if test -n "$ac_subst_files"; then
1906 cat <<\_ASBOX
1907 ## ------------------- ##
1908 ## File substitutions. ##
1909 ## ------------------- ##
1910 _ASBOX
1911 echo
1912 for ac_var in $ac_subst_files
1913 do
1914 eval ac_val=\$$ac_var
1915 case $ac_val in
1916 *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
1917 esac
1918 $as_echo "$ac_var='\''$ac_val'\''"
1919 done | sort
1920 echo
1921 fi
1922
1923 if test -s confdefs.h; then
1924 cat <<\_ASBOX
1925 ## ----------- ##
1926 ## confdefs.h. ##
1927 ## ----------- ##
1928 _ASBOX
1929 echo
1930 cat confdefs.h
1931 echo
1932 fi
1933 test "$ac_signal" != 0 &&
1934 $as_echo "$as_me: caught signal $ac_signal"
1935 $as_echo "$as_me: exit $exit_status"
1936 } >&5
1937 rm -f core *.core core.conftest.* &&
1938 rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
1939 exit $exit_status
1940 ' 0
1941 for ac_signal in 1 2 13 15; do
1942 trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
1943 done
1944 ac_signal=0
1945
1946 # confdefs.h avoids OS command line length limits that DEFS can exceed.
1947 rm -f -r conftest* confdefs.h
1948
1949 $as_echo "/* confdefs.h */" > confdefs.h
1950
1951 # Predefined preprocessor variables.
1952
1953 cat >>confdefs.h <<_ACEOF
1954 #define PACKAGE_NAME "$PACKAGE_NAME"
1955 _ACEOF
1956
1957 cat >>confdefs.h <<_ACEOF
1958 #define PACKAGE_TARNAME "$PACKAGE_TARNAME"
1959 _ACEOF
1960
1961 cat >>confdefs.h <<_ACEOF
1962 #define PACKAGE_VERSION "$PACKAGE_VERSION"
1963 _ACEOF
1964
1965 cat >>confdefs.h <<_ACEOF
1966 #define PACKAGE_STRING "$PACKAGE_STRING"
1967 _ACEOF
1968
1969 cat >>confdefs.h <<_ACEOF
1970 #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
1971 _ACEOF
1972
1973 cat >>confdefs.h <<_ACEOF
1974 #define PACKAGE_URL "$PACKAGE_URL"
1975 _ACEOF
1976
1977
1978 # Let the site file select an alternate cache file if it wants to.
1979 # Prefer an explicitly selected file to automatically selected ones.
1980 ac_site_file1=NONE
1981 ac_site_file2=NONE
1982 if test -n "$CONFIG_SITE"; then
1983 ac_site_file1=$CONFIG_SITE
1984 elif test "x$prefix" != xNONE; then
1985 ac_site_file1=$prefix/share/config.site
1986 ac_site_file2=$prefix/etc/config.site
1987 else
1988 ac_site_file1=$ac_default_prefix/share/config.site
1989 ac_site_file2=$ac_default_prefix/etc/config.site
1990 fi
1991 for ac_site_file in "$ac_site_file1" "$ac_site_file2"
1992 do
1993 test "x$ac_site_file" = xNONE && continue
1994 if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
1995 { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
1996 $as_echo "$as_me: loading site script $ac_site_file" >&6;}
1997 sed 's/^/| /' "$ac_site_file" >&5
1998 . "$ac_site_file"
1999 fi
2000 done
2001
2002 if test -r "$cache_file"; then
2003 # Some versions of bash will fail to source /dev/null (special files
2004 # actually), so we avoid doing that. DJGPP emulates it as a regular file.
2005 if test /dev/null != "$cache_file" && test -f "$cache_file"; then
2006 { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
2007 $as_echo "$as_me: loading cache $cache_file" >&6;}
2008 case $cache_file in
2009 [\\/]* | ?:[\\/]* ) . "$cache_file";;
2010 *) . "./$cache_file";;
2011 esac
2012 fi
2013 else
2014 { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
2015 $as_echo "$as_me: creating cache $cache_file" >&6;}
2016 >$cache_file
2017 fi
2018
2019 # Check that the precious variables saved in the cache have kept the same
2020 # value.
2021 ac_cache_corrupted=false
2022 for ac_var in $ac_precious_vars; do
2023 eval ac_old_set=\$ac_cv_env_${ac_var}_set
2024 eval ac_new_set=\$ac_env_${ac_var}_set
2025 eval ac_old_val=\$ac_cv_env_${ac_var}_value
2026 eval ac_new_val=\$ac_env_${ac_var}_value
2027 case $ac_old_set,$ac_new_set in
2028 set,)
2029 { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
2030 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
2031 ac_cache_corrupted=: ;;
2032 ,set)
2033 { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
2034 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
2035 ac_cache_corrupted=: ;;
2036 ,);;
2037 *)
2038 if test "x$ac_old_val" != "x$ac_new_val"; then
2039 # differences in whitespace do not lead to failure.
2040 ac_old_val_w=`echo x $ac_old_val`
2041 ac_new_val_w=`echo x $ac_new_val`
2042 if test "$ac_old_val_w" != "$ac_new_val_w"; then
2043 { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
2044 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
2045 ac_cache_corrupted=:
2046 else
2047 { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
2048 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
2049 eval $ac_var=\$ac_old_val
2050 fi
2051 { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
2052 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
2053 { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
2054 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
2055 fi;;
2056 esac
2057 # Pass precious variables to config.status.
2058 if test "$ac_new_set" = set; then
2059 case $ac_new_val in
2060 *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
2061 *) ac_arg=$ac_var=$ac_new_val ;;
2062 esac
2063 case " $ac_configure_args " in
2064 *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
2065 *) as_fn_append ac_configure_args " '$ac_arg'" ;;
2066 esac
2067 fi
2068 done
2069 if $ac_cache_corrupted; then
2070 { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2071 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2072 { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
2073 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
2074 as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
2075 fi
2076 ## -------------------- ##
2077 ## Main body of script. ##
2078 ## -------------------- ##
2079
2080 ac_ext=c
2081 ac_cpp='$CPP $CPPFLAGS'
2082 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
2083 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
2084 ac_compiler_gnu=$ac_cv_c_compiler_gnu
2085
2086
2087
2088
2089 ac_config_headers="$ac_config_headers config.h"
2090
2091
2092
2093 am__api_version='1.11'
2094
2095 ac_aux_dir=
2096 for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
2097 for ac_t in install-sh install.sh shtool; do
2098 if test -f "$ac_dir/$ac_t"; then
2099 ac_aux_dir=$ac_dir
2100 ac_install_sh="$ac_aux_dir/$ac_t -c"
2101 break 2
2102 fi
2103 done
2104 done
2105 if test -z "$ac_aux_dir"; then
2106 as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
2107 fi
2108
2109 # These three variables are undocumented and unsupported,
2110 # and are intended to be withdrawn in a future Autoconf release.
2111 # They can cause serious problems if a builder's source tree is in a directory
2112 # whose full name contains unusual characters.
2113 ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
2114 ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
2115 ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
2116
2117
2118 # Find a good install program. We prefer a C program (faster),
2119 # so one script is as good as another. But avoid the broken or
2120 # incompatible versions:
2121 # SysV /etc/install, /usr/sbin/install
2122 # SunOS /usr/etc/install
2123 # IRIX /sbin/install
2124 # AIX /bin/install
2125 # AmigaOS /C/install, which installs bootblocks on floppy discs
2126 # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
2127 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
2128 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
2129 # OS/2's system install, which has a completely different semantic
2130 # ./install, which can be erroneously created by make from ./install.sh.
2131 # Reject install programs that cannot install multiple files.
2132 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
2133 $as_echo_n "checking for a BSD-compatible install... " >&6; }
2134 if test -z "$INSTALL"; then
2135 if test "${ac_cv_path_install+set}" = set; then :
2136 $as_echo_n "(cached) " >&6
2137 else
2138 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2139 for as_dir in $PATH
2140 do
2141 IFS=$as_save_IFS
2142 test -z "$as_dir" && as_dir=.
2143 # Account for people who put trailing slashes in PATH elements.
2144 case $as_dir/ in #((
2145 ./ | .// | /[cC]/* | \
2146 /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
2147 ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
2148 /usr/ucb/* ) ;;
2149 *)
2150 # OSF1 and SCO ODT 3.0 have their own names for install.
2151 # Don't use installbsd from OSF since it installs stuff as root
2152 # by default.
2153 for ac_prog in ginstall scoinst install; do
2154 for ac_exec_ext in '' $ac_executable_extensions; do
2155 if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
2156 if test $ac_prog = install &&
2157 grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
2158 # AIX install. It has an incompatible calling convention.
2159 :
2160 elif test $ac_prog = install &&
2161 grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
2162 # program-specific install script used by HP pwplus--don't use.
2163 :
2164 else
2165 rm -rf conftest.one conftest.two conftest.dir
2166 echo one > conftest.one
2167 echo two > conftest.two
2168 mkdir conftest.dir
2169 if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
2170 test -s conftest.one && test -s conftest.two &&
2171 test -s conftest.dir/conftest.one &&
2172 test -s conftest.dir/conftest.two
2173 then
2174 ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
2175 break 3
2176 fi
2177 fi
2178 fi
2179 done
2180 done
2181 ;;
2182 esac
2183
2184 done
2185 IFS=$as_save_IFS
2186
2187 rm -rf conftest.one conftest.two conftest.dir
2188
2189 fi
2190 if test "${ac_cv_path_install+set}" = set; then
2191 INSTALL=$ac_cv_path_install
2192 else
2193 # As a last resort, use the slow shell script. Don't cache a
2194 # value for INSTALL within a source directory, because that will
2195 # break other packages using the cache if that directory is
2196 # removed, or if the value is a relative name.
2197 INSTALL=$ac_install_sh
2198 fi
2199 fi
2200 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
2201 $as_echo "$INSTALL" >&6; }
2202
2203 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
2204 # It thinks the first close brace ends the variable substitution.
2205 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
2206
2207 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
2208
2209 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
2210
2211 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
2212 $as_echo_n "checking whether build environment is sane... " >&6; }
2213 # Just in case
2214 sleep 1
2215 echo timestamp > conftest.file
2216 # Reject unsafe characters in $srcdir or the absolute working directory
2217 # name. Accept space and tab only in the latter.
2218 am_lf='
2219 '
2220 case `pwd` in
2221 *[\\\"\#\$\&\'\`$am_lf]*)
2222 as_fn_error "unsafe absolute working directory name" "$LINENO" 5;;
2223 esac
2224 case $srcdir in
2225 *[\\\"\#\$\&\'\`$am_lf\ \ ]*)
2226 as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
2227 esac
2228
2229 # Do `set' in a subshell so we don't clobber the current shell's
2230 # arguments. Must try -L first in case configure is actually a
2231 # symlink; some systems play weird games with the mod time of symlinks
2232 # (eg FreeBSD returns the mod time of the symlink's containing
2233 # directory).
2234 if (
2235 set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
2236 if test "$*" = "X"; then
2237 # -L didn't work.
2238 set X `ls -t "$srcdir/configure" conftest.file`
2239 fi
2240 rm -f conftest.file
2241 if test "$*" != "X $srcdir/configure conftest.file" \
2242 && test "$*" != "X conftest.file $srcdir/configure"; then
2243
2244 # If neither matched, then we have a broken ls. This can happen
2245 # if, for instance, CONFIG_SHELL is bash and it inherits a
2246 # broken ls alias from the environment. This has actually
2247 # happened. Such a system could not be considered "sane".
2248 as_fn_error "ls -t appears to fail. Make sure there is not a broken
2249 alias in your environment" "$LINENO" 5
2250 fi
2251
2252 test "$2" = conftest.file
2253 )
2254 then
2255 # Ok.
2256 :
2257 else
2258 as_fn_error "newly created file is older than distributed files!
2259 Check your system clock" "$LINENO" 5
2260 fi
2261 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
2262 $as_echo "yes" >&6; }
2263 test "$program_prefix" != NONE &&
2264 program_transform_name="s&^&$program_prefix&;$program_transform_name"
2265 # Use a double $ so make ignores it.
2266 test "$program_suffix" != NONE &&
2267 program_transform_name="s&\$&$program_suffix&;$program_transform_name"
2268 # Double any \ or $.
2269 # By default was `s,x,x', remove it if useless.
2270 ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
2271 program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
2272
2273 # expand $ac_aux_dir to an absolute path
2274 am_aux_dir=`cd $ac_aux_dir && pwd`
2275
2276 if test x"${MISSING+set}" != xset; then
2277 case $am_aux_dir in
2278 *\ * | *\ *)
2279 MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
2280 *)
2281 MISSING="\${SHELL} $am_aux_dir/missing" ;;
2282 esac
2283 fi
2284 # Use eval to expand $SHELL
2285 if eval "$MISSING --run true"; then
2286 am_missing_run="$MISSING --run "
2287 else
2288 am_missing_run=
2289 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
2290 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
2291 fi
2292
2293 if test x"${install_sh}" != xset; then
2294 case $am_aux_dir in
2295 *\ * | *\ *)
2296 install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
2297 *)
2298 install_sh="\${SHELL} $am_aux_dir/install-sh"
2299 esac
2300 fi
2301
2302 # Installed binaries are usually stripped using `strip' when the user
2303 # run `make install-strip'. However `strip' might not be the right
2304 # tool to use in cross-compilation environments, therefore Automake
2305 # will honor the `STRIP' environment variable to overrule this program.
2306 if test "$cross_compiling" != no; then
2307 if test -n "$ac_tool_prefix"; then
2308 # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
2309 set dummy ${ac_tool_prefix}strip; ac_word=$2
2310 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2311 $as_echo_n "checking for $ac_word... " >&6; }
2312 if test "${ac_cv_prog_STRIP+set}" = set; then :
2313 $as_echo_n "(cached) " >&6
2314 else
2315 if test -n "$STRIP"; then
2316 ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
2317 else
2318 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2319 for as_dir in $PATH
2320 do
2321 IFS=$as_save_IFS
2322 test -z "$as_dir" && as_dir=.
2323 for ac_exec_ext in '' $ac_executable_extensions; do
2324 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2325 ac_cv_prog_STRIP="${ac_tool_prefix}strip"
2326 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2327 break 2
2328 fi
2329 done
2330 done
2331 IFS=$as_save_IFS
2332
2333 fi
2334 fi
2335 STRIP=$ac_cv_prog_STRIP
2336 if test -n "$STRIP"; then
2337 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
2338 $as_echo "$STRIP" >&6; }
2339 else
2340 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2341 $as_echo "no" >&6; }
2342 fi
2343
2344
2345 fi
2346 if test -z "$ac_cv_prog_STRIP"; then
2347 ac_ct_STRIP=$STRIP
2348 # Extract the first word of "strip", so it can be a program name with args.
2349 set dummy strip; ac_word=$2
2350 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2351 $as_echo_n "checking for $ac_word... " >&6; }
2352 if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
2353 $as_echo_n "(cached) " >&6
2354 else
2355 if test -n "$ac_ct_STRIP"; then
2356 ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
2357 else
2358 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2359 for as_dir in $PATH
2360 do
2361 IFS=$as_save_IFS
2362 test -z "$as_dir" && as_dir=.
2363 for ac_exec_ext in '' $ac_executable_extensions; do
2364 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2365 ac_cv_prog_ac_ct_STRIP="strip"
2366 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2367 break 2
2368 fi
2369 done
2370 done
2371 IFS=$as_save_IFS
2372
2373 fi
2374 fi
2375 ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
2376 if test -n "$ac_ct_STRIP"; then
2377 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
2378 $as_echo "$ac_ct_STRIP" >&6; }
2379 else
2380 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2381 $as_echo "no" >&6; }
2382 fi
2383
2384 if test "x$ac_ct_STRIP" = x; then
2385 STRIP=":"
2386 else
2387 case $cross_compiling:$ac_tool_warned in
2388 yes:)
2389 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
2390 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
2391 ac_tool_warned=yes ;;
2392 esac
2393 STRIP=$ac_ct_STRIP
2394 fi
2395 else
2396 STRIP="$ac_cv_prog_STRIP"
2397 fi
2398
2399 fi
2400 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
2401
2402 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
2403 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
2404 if test -z "$MKDIR_P"; then
2405 if test "${ac_cv_path_mkdir+set}" = set; then :
2406 $as_echo_n "(cached) " >&6
2407 else
2408 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2409 for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
2410 do
2411 IFS=$as_save_IFS
2412 test -z "$as_dir" && as_dir=.
2413 for ac_prog in mkdir gmkdir; do
2414 for ac_exec_ext in '' $ac_executable_extensions; do
2415 { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
2416 case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
2417 'mkdir (GNU coreutils) '* | \
2418 'mkdir (coreutils) '* | \
2419 'mkdir (fileutils) '4.1*)
2420 ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
2421 break 3;;
2422 esac
2423 done
2424 done
2425 done
2426 IFS=$as_save_IFS
2427
2428 fi
2429
2430 test -d ./--version && rmdir ./--version
2431 if test "${ac_cv_path_mkdir+set}" = set; then
2432 MKDIR_P="$ac_cv_path_mkdir -p"
2433 else
2434 # As a last resort, use the slow shell script. Don't cache a
2435 # value for MKDIR_P within a source directory, because that will
2436 # break other packages using the cache if that directory is
2437 # removed, or if the value is a relative name.
2438 MKDIR_P="$ac_install_sh -d"
2439 fi
2440 fi
2441 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
2442 $as_echo "$MKDIR_P" >&6; }
2443
2444 mkdir_p="$MKDIR_P"
2445 case $mkdir_p in
2446 [\\/$]* | ?:[\\/]*) ;;
2447 */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
2448 esac
2449
2450 for ac_prog in gawk mawk nawk awk
2451 do
2452 # Extract the first word of "$ac_prog", so it can be a program name with args.
2453 set dummy $ac_prog; ac_word=$2
2454 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2455 $as_echo_n "checking for $ac_word... " >&6; }
2456 if test "${ac_cv_prog_AWK+set}" = set; then :
2457 $as_echo_n "(cached) " >&6
2458 else
2459 if test -n "$AWK"; then
2460 ac_cv_prog_AWK="$AWK" # Let the user override the test.
2461 else
2462 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2463 for as_dir in $PATH
2464 do
2465 IFS=$as_save_IFS
2466 test -z "$as_dir" && as_dir=.
2467 for ac_exec_ext in '' $ac_executable_extensions; do
2468 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2469 ac_cv_prog_AWK="$ac_prog"
2470 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2471 break 2
2472 fi
2473 done
2474 done
2475 IFS=$as_save_IFS
2476
2477 fi
2478 fi
2479 AWK=$ac_cv_prog_AWK
2480 if test -n "$AWK"; then
2481 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
2482 $as_echo "$AWK" >&6; }
2483 else
2484 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2485 $as_echo "no" >&6; }
2486 fi
2487
2488
2489 test -n "$AWK" && break
2490 done
2491
2492 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
2493 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
2494 set x ${MAKE-make}
2495 ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
2496 if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
2497 $as_echo_n "(cached) " >&6
2498 else
2499 cat >conftest.make <<\_ACEOF
2500 SHELL = /bin/sh
2501 all:
2502 @echo '@@@%%%=$(MAKE)=@@@%%%'
2503 _ACEOF
2504 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
2505 case `${MAKE-make} -f conftest.make 2>/dev/null` in
2506 *@@@%%%=?*=@@@%%%*)
2507 eval ac_cv_prog_make_${ac_make}_set=yes;;
2508 *)
2509 eval ac_cv_prog_make_${ac_make}_set=no;;
2510 esac
2511 rm -f conftest.make
2512 fi
2513 if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
2514 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
2515 $as_echo "yes" >&6; }
2516 SET_MAKE=
2517 else
2518 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2519 $as_echo "no" >&6; }
2520 SET_MAKE="MAKE=${MAKE-make}"
2521 fi
2522
2523 rm -rf .tst 2>/dev/null
2524 mkdir .tst 2>/dev/null
2525 if test -d .tst; then
2526 am__leading_dot=.
2527 else
2528 am__leading_dot=_
2529 fi
2530 rmdir .tst 2>/dev/null
2531
2532 if test "`cd $srcdir && pwd`" != "`pwd`"; then
2533 # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
2534 # is not polluted with repeated "-I."
2535 am__isrc=' -I$(srcdir)'
2536 # test to see if srcdir already configured
2537 if test -f $srcdir/config.status; then
2538 as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
2539 fi
2540 fi
2541
2542 # test whether we have cygpath
2543 if test -z "$CYGPATH_W"; then
2544 if (cygpath --version) >/dev/null 2>/dev/null; then
2545 CYGPATH_W='cygpath -w'
2546 else
2547 CYGPATH_W=echo
2548 fi
2549 fi
2550
2551
2552 # Define the identity of the package.
2553 PACKAGE=beanstalkd
2554 VERSION=$($srcdir/version.sh)
2555
2556
2557 cat >>confdefs.h <<_ACEOF
2558 #define PACKAGE "$PACKAGE"
2559 _ACEOF
2560
2561
2562 cat >>confdefs.h <<_ACEOF
2563 #define VERSION "$VERSION"
2564 _ACEOF
2565
2566 # Some tools Automake needs.
2567
2568 ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
2569
2570
2571 AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
2572
2573
2574 AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
2575
2576
2577 AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
2578
2579
2580 MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
2581
2582 # We need awk for the "check" target. The system "awk" is bad on
2583 # some platforms.
2584 # Always define AMTAR for backward compatibility.
2585
2586 AMTAR=${AMTAR-"${am_missing_run}tar"}
2587
2588 am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
2589
2590
2591
2592
2593
2594
2595 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
2596 $as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; }
2597 # Check whether --enable-maintainer-mode was given.
2598 if test "${enable_maintainer_mode+set}" = set; then :
2599 enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
2600 else
2601 USE_MAINTAINER_MODE=no
2602 fi
2603
2604 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5
2605 $as_echo "$USE_MAINTAINER_MODE" >&6; }
2606 if test $USE_MAINTAINER_MODE = yes; then
2607 MAINTAINER_MODE_TRUE=
2608 MAINTAINER_MODE_FALSE='#'
2609 else
2610 MAINTAINER_MODE_TRUE='#'
2611 MAINTAINER_MODE_FALSE=
2612 fi
2613
2614 MAINT=$MAINTAINER_MODE_TRUE
2615
2616
2617
2618 DEPDIR="${am__leading_dot}deps"
2619
2620 ac_config_commands="$ac_config_commands depfiles"
2621
2622
2623 am_make=${MAKE-make}
2624 cat > confinc << 'END'
2625 am__doit:
2626 @echo this is the am__doit target
2627 .PHONY: am__doit
2628 END
2629 # If we don't find an include directive, just comment out the code.
2630 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
2631 $as_echo_n "checking for style of include used by $am_make... " >&6; }
2632 am__include="#"
2633 am__quote=
2634 _am_result=none
2635 # First try GNU make style include.
2636 echo "include confinc" > confmf
2637 # Ignore all kinds of additional output from `make'.
2638 case `$am_make -s -f confmf 2> /dev/null` in #(
2639 *the\ am__doit\ target*)
2640 am__include=include
2641 am__quote=
2642 _am_result=GNU
2643 ;;
2644 esac
2645 # Now try BSD make style include.
2646 if test "$am__include" = "#"; then
2647 echo '.include "confinc"' > confmf
2648 case `$am_make -s -f confmf 2> /dev/null` in #(
2649 *the\ am__doit\ target*)
2650 am__include=.include
2651 am__quote="\""
2652 _am_result=BSD
2653 ;;
2654 esac
2655 fi
2656
2657
2658 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
2659 $as_echo "$_am_result" >&6; }
2660 rm -f confinc confmf
2661
2662 # Check whether --enable-dependency-tracking was given.
2663 if test "${enable_dependency_tracking+set}" = set; then :
2664 enableval=$enable_dependency_tracking;
2665 fi
2666
2667 if test "x$enable_dependency_tracking" != xno; then
2668 am_depcomp="$ac_aux_dir/depcomp"
2669 AMDEPBACKSLASH='\'
2670 fi
2671 if test "x$enable_dependency_tracking" != xno; then
2672 AMDEP_TRUE=
2673 AMDEP_FALSE='#'
2674 else
2675 AMDEP_TRUE='#'
2676 AMDEP_FALSE=
2677 fi
2678
2679
2680 ac_ext=c
2681 ac_cpp='$CPP $CPPFLAGS'
2682 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
2683 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
2684 ac_compiler_gnu=$ac_cv_c_compiler_gnu
2685 if test -n "$ac_tool_prefix"; then
2686 # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
2687 set dummy ${ac_tool_prefix}gcc; ac_word=$2
2688 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2689 $as_echo_n "checking for $ac_word... " >&6; }
2690 if test "${ac_cv_prog_CC+set}" = set; then :
2691 $as_echo_n "(cached) " >&6
2692 else
2693 if test -n "$CC"; then
2694 ac_cv_prog_CC="$CC" # Let the user override the test.
2695 else
2696 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2697 for as_dir in $PATH
2698 do
2699 IFS=$as_save_IFS
2700 test -z "$as_dir" && as_dir=.
2701 for ac_exec_ext in '' $ac_executable_extensions; do
2702 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2703 ac_cv_prog_CC="${ac_tool_prefix}gcc"
2704 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2705 break 2
2706 fi
2707 done
2708 done
2709 IFS=$as_save_IFS
2710
2711 fi
2712 fi
2713 CC=$ac_cv_prog_CC
2714 if test -n "$CC"; then
2715 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
2716 $as_echo "$CC" >&6; }
2717 else
2718 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2719 $as_echo "no" >&6; }
2720 fi
2721
2722
2723 fi
2724 if test -z "$ac_cv_prog_CC"; then
2725 ac_ct_CC=$CC
2726 # Extract the first word of "gcc", so it can be a program name with args.
2727 set dummy gcc; ac_word=$2
2728 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2729 $as_echo_n "checking for $ac_word... " >&6; }
2730 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
2731 $as_echo_n "(cached) " >&6
2732 else
2733 if test -n "$ac_ct_CC"; then
2734 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
2735 else
2736 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2737 for as_dir in $PATH
2738 do
2739 IFS=$as_save_IFS
2740 test -z "$as_dir" && as_dir=.
2741 for ac_exec_ext in '' $ac_executable_extensions; do
2742 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2743 ac_cv_prog_ac_ct_CC="gcc"
2744 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2745 break 2
2746 fi
2747 done
2748 done
2749 IFS=$as_save_IFS
2750
2751 fi
2752 fi
2753 ac_ct_CC=$ac_cv_prog_ac_ct_CC
2754 if test -n "$ac_ct_CC"; then
2755 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
2756 $as_echo "$ac_ct_CC" >&6; }
2757 else
2758 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2759 $as_echo "no" >&6; }
2760 fi
2761
2762 if test "x$ac_ct_CC" = x; then
2763 CC=""
2764 else
2765 case $cross_compiling:$ac_tool_warned in
2766 yes:)
2767 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
2768 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
2769 ac_tool_warned=yes ;;
2770 esac
2771 CC=$ac_ct_CC
2772 fi
2773 else
2774 CC="$ac_cv_prog_CC"
2775 fi
2776
2777 if test -z "$CC"; then
2778 if test -n "$ac_tool_prefix"; then
2779 # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
2780 set dummy ${ac_tool_prefix}cc; ac_word=$2
2781 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2782 $as_echo_n "checking for $ac_word... " >&6; }
2783 if test "${ac_cv_prog_CC+set}" = set; then :
2784 $as_echo_n "(cached) " >&6
2785 else
2786 if test -n "$CC"; then
2787 ac_cv_prog_CC="$CC" # Let the user override the test.
2788 else
2789 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2790 for as_dir in $PATH
2791 do
2792 IFS=$as_save_IFS
2793 test -z "$as_dir" && as_dir=.
2794 for ac_exec_ext in '' $ac_executable_extensions; do
2795 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2796 ac_cv_prog_CC="${ac_tool_prefix}cc"
2797 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2798 break 2
2799 fi
2800 done
2801 done
2802 IFS=$as_save_IFS
2803
2804 fi
2805 fi
2806 CC=$ac_cv_prog_CC
2807 if test -n "$CC"; then
2808 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
2809 $as_echo "$CC" >&6; }
2810 else
2811 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2812 $as_echo "no" >&6; }
2813 fi
2814
2815
2816 fi
2817 fi
2818 if test -z "$CC"; then
2819 # Extract the first word of "cc", so it can be a program name with args.
2820 set dummy cc; ac_word=$2
2821 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2822 $as_echo_n "checking for $ac_word... " >&6; }
2823 if test "${ac_cv_prog_CC+set}" = set; then :
2824 $as_echo_n "(cached) " >&6
2825 else
2826 if test -n "$CC"; then
2827 ac_cv_prog_CC="$CC" # Let the user override the test.
2828 else
2829 ac_prog_rejected=no
2830 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2831 for as_dir in $PATH
2832 do
2833 IFS=$as_save_IFS
2834 test -z "$as_dir" && as_dir=.
2835 for ac_exec_ext in '' $ac_executable_extensions; do
2836 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2837 if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
2838 ac_prog_rejected=yes
2839 continue
2840 fi
2841 ac_cv_prog_CC="cc"
2842 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2843 break 2
2844 fi
2845 done
2846 done
2847 IFS=$as_save_IFS
2848
2849 if test $ac_prog_rejected = yes; then
2850 # We found a bogon in the path, so make sure we never use it.
2851 set dummy $ac_cv_prog_CC
2852 shift
2853 if test $# != 0; then
2854 # We chose a different compiler from the bogus one.
2855 # However, it has the same basename, so the bogon will be chosen
2856 # first if we set CC to just the basename; use the full file name.
2857 shift
2858 ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
2859 fi
2860 fi
2861 fi
2862 fi
2863 CC=$ac_cv_prog_CC
2864 if test -n "$CC"; then
2865 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
2866 $as_echo "$CC" >&6; }
2867 else
2868 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2869 $as_echo "no" >&6; }
2870 fi
2871
2872
2873 fi
2874 if test -z "$CC"; then
2875 if test -n "$ac_tool_prefix"; then
2876 for ac_prog in cl.exe
2877 do
2878 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
2879 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
2880 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2881 $as_echo_n "checking for $ac_word... " >&6; }
2882 if test "${ac_cv_prog_CC+set}" = set; then :
2883 $as_echo_n "(cached) " >&6
2884 else
2885 if test -n "$CC"; then
2886 ac_cv_prog_CC="$CC" # Let the user override the test.
2887 else
2888 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2889 for as_dir in $PATH
2890 do
2891 IFS=$as_save_IFS
2892 test -z "$as_dir" && as_dir=.
2893 for ac_exec_ext in '' $ac_executable_extensions; do
2894 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2895 ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
2896 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2897 break 2
2898 fi
2899 done
2900 done
2901 IFS=$as_save_IFS
2902
2903 fi
2904 fi
2905 CC=$ac_cv_prog_CC
2906 if test -n "$CC"; then
2907 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
2908 $as_echo "$CC" >&6; }
2909 else
2910 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2911 $as_echo "no" >&6; }
2912 fi
2913
2914
2915 test -n "$CC" && break
2916 done
2917 fi
2918 if test -z "$CC"; then
2919 ac_ct_CC=$CC
2920 for ac_prog in cl.exe
2921 do
2922 # Extract the first word of "$ac_prog", so it can be a program name with args.
2923 set dummy $ac_prog; ac_word=$2
2924 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2925 $as_echo_n "checking for $ac_word... " >&6; }
2926 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
2927 $as_echo_n "(cached) " >&6
2928 else
2929 if test -n "$ac_ct_CC"; then
2930 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
2931 else
2932 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2933 for as_dir in $PATH
2934 do
2935 IFS=$as_save_IFS
2936 test -z "$as_dir" && as_dir=.
2937 for ac_exec_ext in '' $ac_executable_extensions; do
2938 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
2939 ac_cv_prog_ac_ct_CC="$ac_prog"
2940 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2941 break 2
2942 fi
2943 done
2944 done
2945 IFS=$as_save_IFS
2946
2947 fi
2948 fi
2949 ac_ct_CC=$ac_cv_prog_ac_ct_CC
2950 if test -n "$ac_ct_CC"; then
2951 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
2952 $as_echo "$ac_ct_CC" >&6; }
2953 else
2954 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2955 $as_echo "no" >&6; }
2956 fi
2957
2958
2959 test -n "$ac_ct_CC" && break
2960 done
2961
2962 if test "x$ac_ct_CC" = x; then
2963 CC=""
2964 else
2965 case $cross_compiling:$ac_tool_warned in
2966 yes:)
2967 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
2968 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
2969 ac_tool_warned=yes ;;
2970 esac
2971 CC=$ac_ct_CC
2972 fi
2973 fi
2974
2975 fi
2976
2977
2978 test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
2979 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
2980 as_fn_error "no acceptable C compiler found in \$PATH
2981 See \`config.log' for more details." "$LINENO" 5; }
2982
2983 # Provide some information about the compiler.
2984 $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
2985 set X $ac_compile
2986 ac_compiler=$2
2987 for ac_option in --version -v -V -qversion; do
2988 { { ac_try="$ac_compiler $ac_option >&5"
2989 case "(($ac_try" in
2990 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
2991 *) ac_try_echo=$ac_try;;
2992 esac
2993 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
2994 $as_echo "$ac_try_echo"; } >&5
2995 (eval "$ac_compiler $ac_option >&5") 2>conftest.err
2996 ac_status=$?
2997 if test -s conftest.err; then
2998 sed '10a\
2999 ... rest of stderr output deleted ...
3000 10q' conftest.err >conftest.er1
3001 cat conftest.er1 >&5
3002 fi
3003 rm -f conftest.er1 conftest.err
3004 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
3005 test $ac_status = 0; }
3006 done
3007
3008 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3009 /* end confdefs.h. */
3010
3011 int
3012 main ()
3013 {
3014
3015 ;
3016 return 0;
3017 }
3018 _ACEOF
3019 ac_clean_files_save=$ac_clean_files
3020 ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
3021 # Try to create an executable without -o first, disregard a.out.
3022 # It will help us diagnose broken compilers, and finding out an intuition
3023 # of exeext.
3024 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
3025 $as_echo_n "checking whether the C compiler works... " >&6; }
3026 ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
3027
3028 # The possible output files:
3029 ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
3030
3031 ac_rmfiles=
3032 for ac_file in $ac_files
3033 do
3034 case $ac_file in
3035 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
3036 * ) ac_rmfiles="$ac_rmfiles $ac_file";;
3037 esac
3038 done
3039 rm -f $ac_rmfiles
3040
3041 if { { ac_try="$ac_link_default"
3042 case "(($ac_try" in
3043 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3044 *) ac_try_echo=$ac_try;;
3045 esac
3046 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
3047 $as_echo "$ac_try_echo"; } >&5
3048 (eval "$ac_link_default") 2>&5
3049 ac_status=$?
3050 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
3051 test $ac_status = 0; }; then :
3052 # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
3053 # So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
3054 # in a Makefile. We should not override ac_cv_exeext if it was cached,
3055 # so that the user can short-circuit this test for compilers unknown to
3056 # Autoconf.
3057 for ac_file in $ac_files ''
3058 do
3059 test -f "$ac_file" || continue
3060 case $ac_file in
3061 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
3062 ;;
3063 [ab].out )
3064 # We found the default executable, but exeext='' is most
3065 # certainly right.
3066 break;;
3067 *.* )
3068 if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
3069 then :; else
3070 ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
3071 fi
3072 # We set ac_cv_exeext here because the later test for it is not
3073 # safe: cross compilers may not add the suffix if given an `-o'
3074 # argument, so we may need to know it at that point already.
3075 # Even if this section looks crufty: it has the advantage of
3076 # actually working.
3077 break;;
3078 * )
3079 break;;
3080 esac
3081 done
3082 test "$ac_cv_exeext" = no && ac_cv_exeext=
3083
3084 else
3085 ac_file=''
3086 fi
3087 if test -z "$ac_file"; then :
3088 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3089 $as_echo "no" >&6; }
3090 $as_echo "$as_me: failed program was:" >&5
3091 sed 's/^/| /' conftest.$ac_ext >&5
3092
3093 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
3094 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3095 { as_fn_set_status 77
3096 as_fn_error "C compiler cannot create executables
3097 See \`config.log' for more details." "$LINENO" 5; }; }
3098 else
3099 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
3100 $as_echo "yes" >&6; }
3101 fi
3102 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
3103 $as_echo_n "checking for C compiler default output file name... " >&6; }
3104 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
3105 $as_echo "$ac_file" >&6; }
3106 ac_exeext=$ac_cv_exeext
3107
3108 rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
3109 ac_clean_files=$ac_clean_files_save
3110 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
3111 $as_echo_n "checking for suffix of executables... " >&6; }
3112 if { { ac_try="$ac_link"
3113 case "(($ac_try" in
3114 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3115 *) ac_try_echo=$ac_try;;
3116 esac
3117 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
3118 $as_echo "$ac_try_echo"; } >&5
3119 (eval "$ac_link") 2>&5
3120 ac_status=$?
3121 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
3122 test $ac_status = 0; }; then :
3123 # If both `conftest.exe' and `conftest' are `present' (well, observable)
3124 # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
3125 # work properly (i.e., refer to `conftest.exe'), while it won't with
3126 # `rm'.
3127 for ac_file in conftest.exe conftest conftest.*; do
3128 test -f "$ac_file" || continue
3129 case $ac_file in
3130 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
3131 *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
3132 break;;
3133 * ) break;;
3134 esac
3135 done
3136 else
3137 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
3138 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3139 as_fn_error "cannot compute suffix of executables: cannot compile and link
3140 See \`config.log' for more details." "$LINENO" 5; }
3141 fi
3142 rm -f conftest conftest$ac_cv_exeext
3143 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
3144 $as_echo "$ac_cv_exeext" >&6; }
3145
3146 rm -f conftest.$ac_ext
3147 EXEEXT=$ac_cv_exeext
3148 ac_exeext=$EXEEXT
3149 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3150 /* end confdefs.h. */
3151 #include <stdio.h>
3152 int
3153 main ()
3154 {
3155 FILE *f = fopen ("conftest.out", "w");
3156 return ferror (f) || fclose (f) != 0;
3157
3158 ;
3159 return 0;
3160 }
3161 _ACEOF
3162 ac_clean_files="$ac_clean_files conftest.out"
3163 # Check that the compiler produces executables we can run. If not, either
3164 # the compiler is broken, or we cross compile.
3165 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
3166 $as_echo_n "checking whether we are cross compiling... " >&6; }
3167 if test "$cross_compiling" != yes; then
3168 { { ac_try="$ac_link"
3169 case "(($ac_try" in
3170 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3171 *) ac_try_echo=$ac_try;;
3172 esac
3173 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
3174 $as_echo "$ac_try_echo"; } >&5
3175 (eval "$ac_link") 2>&5
3176 ac_status=$?
3177 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
3178 test $ac_status = 0; }
3179 if { ac_try='./conftest$ac_cv_exeext'
3180 { { case "(($ac_try" in
3181 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3182 *) ac_try_echo=$ac_try;;
3183 esac
3184 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
3185 $as_echo "$ac_try_echo"; } >&5
3186 (eval "$ac_try") 2>&5
3187 ac_status=$?
3188 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
3189 test $ac_status = 0; }; }; then
3190 cross_compiling=no
3191 else
3192 if test "$cross_compiling" = maybe; then
3193 cross_compiling=yes
3194 else
3195 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
3196 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3197 as_fn_error "cannot run C compiled programs.
3198 If you meant to cross compile, use \`--host'.
3199 See \`config.log' for more details." "$LINENO" 5; }
3200 fi
3201 fi
3202 fi
3203 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
3204 $as_echo "$cross_compiling" >&6; }
3205
3206 rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
3207 ac_clean_files=$ac_clean_files_save
3208 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
3209 $as_echo_n "checking for suffix of object files... " >&6; }
3210 if test "${ac_cv_objext+set}" = set; then :
3211 $as_echo_n "(cached) " >&6
3212 else
3213 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3214 /* end confdefs.h. */
3215
3216 int
3217 main ()
3218 {
3219
3220 ;
3221 return 0;
3222 }
3223 _ACEOF
3224 rm -f conftest.o conftest.obj
3225 if { { ac_try="$ac_compile"
3226 case "(($ac_try" in
3227 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3228 *) ac_try_echo=$ac_try;;
3229 esac
3230 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
3231 $as_echo "$ac_try_echo"; } >&5
3232 (eval "$ac_compile") 2>&5
3233 ac_status=$?
3234 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
3235 test $ac_status = 0; }; then :
3236 for ac_file in conftest.o conftest.obj conftest.*; do
3237 test -f "$ac_file" || continue;
3238 case $ac_file in
3239 *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
3240 *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
3241 break;;
3242 esac
3243 done
3244 else
3245 $as_echo "$as_me: failed program was:" >&5
3246 sed 's/^/| /' conftest.$ac_ext >&5
3247
3248 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
3249 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3250 as_fn_error "cannot compute suffix of object files: cannot compile
3251 See \`config.log' for more details." "$LINENO" 5; }
3252 fi
3253 rm -f conftest.$ac_cv_objext conftest.$ac_ext
3254 fi
3255 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
3256 $as_echo "$ac_cv_objext" >&6; }
3257 OBJEXT=$ac_cv_objext
3258 ac_objext=$OBJEXT
3259 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
3260 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
3261 if test "${ac_cv_c_compiler_gnu+set}" = set; then :
3262 $as_echo_n "(cached) " >&6
3263 else
3264 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3265 /* end confdefs.h. */
3266
3267 int
3268 main ()
3269 {
3270 #ifndef __GNUC__
3271 choke me
3272 #endif
3273
3274 ;
3275 return 0;
3276 }
3277 _ACEOF
3278 if ac_fn_c_try_compile "$LINENO"; then :
3279 ac_compiler_gnu=yes
3280 else
3281 ac_compiler_gnu=no
3282 fi
3283 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3284 ac_cv_c_compiler_gnu=$ac_compiler_gnu
3285
3286 fi
3287 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
3288 $as_echo "$ac_cv_c_compiler_gnu" >&6; }
3289 if test $ac_compiler_gnu = yes; then
3290 GCC=yes
3291 else
3292 GCC=
3293 fi
3294 ac_test_CFLAGS=${CFLAGS+set}
3295 ac_save_CFLAGS=$CFLAGS
3296 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
3297 $as_echo_n "checking whether $CC accepts -g... " >&6; }
3298 if test "${ac_cv_prog_cc_g+set}" = set; then :
3299 $as_echo_n "(cached) " >&6
3300 else
3301 ac_save_c_werror_flag=$ac_c_werror_flag
3302 ac_c_werror_flag=yes
3303 ac_cv_prog_cc_g=no
3304 CFLAGS="-g"
3305 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3306 /* end confdefs.h. */
3307
3308 int
3309 main ()
3310 {
3311
3312 ;
3313 return 0;
3314 }
3315 _ACEOF
3316 if ac_fn_c_try_compile "$LINENO"; then :
3317 ac_cv_prog_cc_g=yes
3318 else
3319 CFLAGS=""
3320 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3321 /* end confdefs.h. */
3322
3323 int
3324 main ()
3325 {
3326
3327 ;
3328 return 0;
3329 }
3330 _ACEOF
3331 if ac_fn_c_try_compile "$LINENO"; then :
3332
3333 else
3334 ac_c_werror_flag=$ac_save_c_werror_flag
3335 CFLAGS="-g"
3336 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3337 /* end confdefs.h. */
3338
3339 int
3340 main ()
3341 {
3342
3343 ;
3344 return 0;
3345 }
3346 _ACEOF
3347 if ac_fn_c_try_compile "$LINENO"; then :
3348 ac_cv_prog_cc_g=yes
3349 fi
3350 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3351 fi
3352 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3353 fi
3354 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3355 ac_c_werror_flag=$ac_save_c_werror_flag
3356 fi
3357 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
3358 $as_echo "$ac_cv_prog_cc_g" >&6; }
3359 if test "$ac_test_CFLAGS" = set; then
3360 CFLAGS=$ac_save_CFLAGS
3361 elif test $ac_cv_prog_cc_g = yes; then
3362 if test "$GCC" = yes; then
3363 CFLAGS="-g -O2"
3364 else
3365 CFLAGS="-g"
3366 fi
3367 else
3368 if test "$GCC" = yes; then
3369 CFLAGS="-O2"
3370 else
3371 CFLAGS=
3372 fi
3373 fi
3374 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
3375 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
3376 if test "${ac_cv_prog_cc_c89+set}" = set; then :
3377 $as_echo_n "(cached) " >&6
3378 else
3379 ac_cv_prog_cc_c89=no
3380 ac_save_CC=$CC
3381 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3382 /* end confdefs.h. */
3383 #include <stdarg.h>
3384 #include <stdio.h>
3385 #include <sys/types.h>
3386 #include <sys/stat.h>
3387 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
3388 struct buf { int x; };
3389 FILE * (*rcsopen) (struct buf *, struct stat *, int);
3390 static char *e (p, i)
3391 char **p;
3392 int i;
3393 {
3394 return p[i];
3395 }
3396 static char *f (char * (*g) (char **, int), char **p, ...)
3397 {
3398 char *s;
3399 va_list v;
3400 va_start (v,p);
3401 s = g (p, va_arg (v,int));
3402 va_end (v);
3403 return s;
3404 }
3405
3406 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
3407 function prototypes and stuff, but not '\xHH' hex character constants.
3408 These don't provoke an error unfortunately, instead are silently treated
3409 as 'x'. The following induces an error, until -std is added to get
3410 proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
3411 array size at least. It's necessary to write '\x00'==0 to get something
3412 that's true only with -std. */
3413 int osf4_cc_array ['\x00' == 0 ? 1 : -1];
3414
3415 /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
3416 inside strings and character constants. */
3417 #define FOO(x) 'x'
3418 int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
3419
3420 int test (int i, double x);
3421 struct s1 {int (*f) (int a);};
3422 struct s2 {int (*f) (double a);};
3423 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
3424 int argc;
3425 char **argv;
3426 int
3427 main ()
3428 {
3429 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
3430 ;
3431 return 0;
3432 }
3433 _ACEOF
3434 for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
3435 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
3436 do
3437 CC="$ac_save_CC $ac_arg"
3438 if ac_fn_c_try_compile "$LINENO"; then :
3439 ac_cv_prog_cc_c89=$ac_arg
3440 fi
3441 rm -f core conftest.err conftest.$ac_objext
3442 test "x$ac_cv_prog_cc_c89" != "xno" && break
3443 done
3444 rm -f conftest.$ac_ext
3445 CC=$ac_save_CC
3446
3447 fi
3448 # AC_CACHE_VAL
3449 case "x$ac_cv_prog_cc_c89" in
3450 x)
3451 { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
3452 $as_echo "none needed" >&6; } ;;
3453 xno)
3454 { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
3455 $as_echo "unsupported" >&6; } ;;
3456 *)
3457 CC="$CC $ac_cv_prog_cc_c89"
3458 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
3459 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
3460 esac
3461 if test "x$ac_cv_prog_cc_c89" != xno; then :
3462
3463 fi
3464
3465 ac_ext=c
3466 ac_cpp='$CPP $CPPFLAGS'
3467 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
3468 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3469 ac_compiler_gnu=$ac_cv_c_compiler_gnu
3470
3471 depcc="$CC" am_compiler_list=
3472
3473 { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
3474 $as_echo_n "checking dependency style of $depcc... " >&6; }
3475 if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
3476 $as_echo_n "(cached) " >&6
3477 else
3478 if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
3479 # We make a subdir and do the tests there. Otherwise we can end up
3480 # making bogus files that we don't know about and never remove. For
3481 # instance it was reported that on HP-UX the gcc test will end up
3482 # making a dummy file named `D' -- because `-MD' means `put the output
3483 # in D'.
3484 mkdir conftest.dir
3485 # Copy depcomp to subdir because otherwise we won't find it if we're
3486 # using a relative directory.
3487 cp "$am_depcomp" conftest.dir
3488 cd conftest.dir
3489 # We will build objects and dependencies in a subdirectory because
3490 # it helps to detect inapplicable dependency modes. For instance
3491 # both Tru64's cc and ICC support -MD to output dependencies as a
3492 # side effect of compilation, but ICC will put the dependencies in
3493 # the current directory while Tru64 will put them in the object
3494 # directory.
3495 mkdir sub
3496
3497 am_cv_CC_dependencies_compiler_type=none
3498 if test "$am_compiler_list" = ""; then
3499 am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
3500 fi
3501 am__universal=false
3502 case " $depcc " in #(
3503 *\ -arch\ *\ -arch\ *) am__universal=true ;;
3504 esac
3505
3506 for depmode in $am_compiler_list; do
3507 # Setup a source with many dependencies, because some compilers
3508 # like to wrap large dependency lists on column 80 (with \), and
3509 # we should not choose a depcomp mode which is confused by this.
3510 #
3511 # We need to recreate these files for each test, as the compiler may
3512 # overwrite some of them when testing with obscure command lines.
3513 # This happens at least with the AIX C compiler.
3514 : > sub/conftest.c
3515 for i in 1 2 3 4 5 6; do
3516 echo '#include "conftst'$i'.h"' >> sub/conftest.c
3517 # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
3518 # Solaris 8's {/usr,}/bin/sh.
3519 touch sub/conftst$i.h
3520 done
3521 echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
3522
3523 # We check with `-c' and `-o' for the sake of the "dashmstdout"
3524 # mode. It turns out that the SunPro C++ compiler does not properly
3525 # handle `-M -o', and we need to detect this. Also, some Intel
3526 # versions had trouble with output in subdirs
3527 am__obj=sub/conftest.${OBJEXT-o}
3528 am__minus_obj="-o $am__obj"
3529 case $depmode in
3530 gcc)
3531 # This depmode causes a compiler race in universal mode.
3532 test "$am__universal" = false || continue
3533 ;;
3534 nosideeffect)
3535 # after this tag, mechanisms are not by side-effect, so they'll
3536 # only be used when explicitly requested
3537 if test "x$enable_dependency_tracking" = xyes; then
3538 continue
3539 else
3540 break
3541 fi
3542 ;;
3543 msvisualcpp | msvcmsys)
3544 # This compiler won't grok `-c -o', but also, the minuso test has
3545 # not run yet. These depmodes are late enough in the game, and
3546 # so weak that their functioning should not be impacted.
3547 am__obj=conftest.${OBJEXT-o}
3548 am__minus_obj=
3549 ;;
3550 none) break ;;
3551 esac
3552 if depmode=$depmode \
3553 source=sub/conftest.c object=$am__obj \
3554 depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
3555 $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
3556 >/dev/null 2>conftest.err &&
3557 grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
3558 grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
3559 grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
3560 ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
3561 # icc doesn't choke on unknown options, it will just issue warnings
3562 # or remarks (even with -Werror). So we grep stderr for any message
3563 # that says an option was ignored or not supported.
3564 # When given -MP, icc 7.0 and 7.1 complain thusly:
3565 # icc: Command line warning: ignoring option '-M'; no argument required
3566 # The diagnosis changed in icc 8.0:
3567 # icc: Command line remark: option '-MP' not supported
3568 if (grep 'ignoring option' conftest.err ||
3569 grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
3570 am_cv_CC_dependencies_compiler_type=$depmode
3571 break
3572 fi
3573 fi
3574 done
3575
3576 cd ..
3577 rm -rf conftest.dir
3578 else
3579 am_cv_CC_dependencies_compiler_type=none
3580 fi
3581
3582 fi
3583 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
3584 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
3585 CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
3586
3587 if
3588 test "x$enable_dependency_tracking" != xno \
3589 && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
3590 am__fastdepCC_TRUE=
3591 am__fastdepCC_FALSE='#'
3592 else
3593 am__fastdepCC_TRUE='#'
3594 am__fastdepCC_FALSE=
3595 fi
3596
3597
3598
3599
3600 list="-Wall -Werror"
3601 flags_supported=""
3602 flags_unsupported=""
3603 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for supported compiler flags" >&5
3604 $as_echo_n "checking for supported compiler flags... " >&6; }
3605 for each in $list
3606 do
3607 save_CFLAGS="$CFLAGS"
3608 CFLAGS="$CFLAGS $each"
3609 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3610 /* end confdefs.h. */
3611
3612 int
3613 main ()
3614 {
3615
3616 ;
3617 return 0;
3618 }
3619 _ACEOF
3620 if ac_fn_c_try_compile "$LINENO"; then :
3621 flag_ok=yes
3622 else
3623 flag_ok=no
3624 fi
3625 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3626 CFLAGS="$save_CFLAGS"
3627
3628 if test "X$flag_ok" = Xyes ; then
3629 flags_supported="$flags_supported $each"
3630 else
3631 flags_unsupported="$flags_unsupported $each"
3632 fi
3633 done
3634 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $flags_supported" >&5
3635 $as_echo "$flags_supported" >&6; }
3636 if test "X$flags_unsupported" != X ; then
3637 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unsupported compiler flags: $flags_unsupported" >&5
3638 $as_echo "$as_me: WARNING: unsupported compiler flags: $flags_unsupported" >&2;}
3639 fi
3640 CFLAGS="$CFLAGS $flags_supported"
3641
3642
3643 ac_ext=c
3644 ac_cpp='$CPP $CPPFLAGS'
3645 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
3646 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
3647 ac_compiler_gnu=$ac_cv_c_compiler_gnu
3648 if test -n "$ac_tool_prefix"; then
3649 # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
3650 set dummy ${ac_tool_prefix}gcc; ac_word=$2
3651 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
3652 $as_echo_n "checking for $ac_word... " >&6; }
3653 if test "${ac_cv_prog_CC+set}" = set; then :
3654 $as_echo_n "(cached) " >&6
3655 else
3656 if test -n "$CC"; then
3657 ac_cv_prog_CC="$CC" # Let the user override the test.
3658 else
3659 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3660 for as_dir in $PATH
3661 do
3662 IFS=$as_save_IFS
3663 test -z "$as_dir" && as_dir=.
3664 for ac_exec_ext in '' $ac_executable_extensions; do
3665 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
3666 ac_cv_prog_CC="${ac_tool_prefix}gcc"
3667 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3668 break 2
3669 fi
3670 done
3671 done
3672 IFS=$as_save_IFS
3673
3674 fi
3675 fi
3676 CC=$ac_cv_prog_CC
3677 if test -n "$CC"; then
3678 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
3679 $as_echo "$CC" >&6; }
3680 else
3681 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3682 $as_echo "no" >&6; }
3683 fi
3684
3685
3686 fi
3687 if test -z "$ac_cv_prog_CC"; then
3688 ac_ct_CC=$CC
3689 # Extract the first word of "gcc", so it can be a program name with args.
3690 set dummy gcc; ac_word=$2
3691 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
3692 $as_echo_n "checking for $ac_word... " >&6; }
3693 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
3694 $as_echo_n "(cached) " >&6
3695 else
3696 if test -n "$ac_ct_CC"; then
3697 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
3698 else
3699 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3700 for as_dir in $PATH
3701 do
3702 IFS=$as_save_IFS
3703 test -z "$as_dir" && as_dir=.
3704 for ac_exec_ext in '' $ac_executable_extensions; do
3705 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
3706 ac_cv_prog_ac_ct_CC="gcc"
3707 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3708 break 2
3709 fi
3710 done
3711 done
3712 IFS=$as_save_IFS
3713
3714 fi
3715 fi
3716 ac_ct_CC=$ac_cv_prog_ac_ct_CC
3717 if test -n "$ac_ct_CC"; then
3718 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
3719 $as_echo "$ac_ct_CC" >&6; }
3720 else
3721 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3722 $as_echo "no" >&6; }
3723 fi
3724
3725 if test "x$ac_ct_CC" = x; then
3726 CC=""
3727 else
3728 case $cross_compiling:$ac_tool_warned in
3729 yes:)
3730 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
3731 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
3732 ac_tool_warned=yes ;;
3733 esac
3734 CC=$ac_ct_CC
3735 fi
3736 else
3737 CC="$ac_cv_prog_CC"
3738 fi
3739
3740 if test -z "$CC"; then
3741 if test -n "$ac_tool_prefix"; then
3742 # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
3743 set dummy ${ac_tool_prefix}cc; ac_word=$2
3744 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
3745 $as_echo_n "checking for $ac_word... " >&6; }
3746 if test "${ac_cv_prog_CC+set}" = set; then :
3747 $as_echo_n "(cached) " >&6
3748 else
3749 if test -n "$CC"; then
3750 ac_cv_prog_CC="$CC" # Let the user override the test.
3751 else
3752 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3753 for as_dir in $PATH
3754 do
3755 IFS=$as_save_IFS
3756 test -z "$as_dir" && as_dir=.
3757 for ac_exec_ext in '' $ac_executable_extensions; do
3758 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
3759 ac_cv_prog_CC="${ac_tool_prefix}cc"
3760 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3761 break 2
3762 fi
3763 done
3764 done
3765 IFS=$as_save_IFS
3766
3767 fi
3768 fi
3769 CC=$ac_cv_prog_CC
3770 if test -n "$CC"; then
3771 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
3772 $as_echo "$CC" >&6; }
3773 else
3774 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3775 $as_echo "no" >&6; }
3776 fi
3777
3778
3779 fi
3780 fi
3781 if test -z "$CC"; then
3782 # Extract the first word of "cc", so it can be a program name with args.
3783 set dummy cc; ac_word=$2
3784 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
3785 $as_echo_n "checking for $ac_word... " >&6; }
3786 if test "${ac_cv_prog_CC+set}" = set; then :
3787 $as_echo_n "(cached) " >&6
3788 else
3789 if test -n "$CC"; then
3790 ac_cv_prog_CC="$CC" # Let the user override the test.
3791 else
3792 ac_prog_rejected=no
3793 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3794 for as_dir in $PATH
3795 do
3796 IFS=$as_save_IFS
3797 test -z "$as_dir" && as_dir=.
3798 for ac_exec_ext in '' $ac_executable_extensions; do
3799 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
3800 if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
3801 ac_prog_rejected=yes
3802 continue
3803 fi
3804 ac_cv_prog_CC="cc"
3805 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3806 break 2
3807 fi
3808 done
3809 done
3810 IFS=$as_save_IFS
3811
3812 if test $ac_prog_rejected = yes; then
3813 # We found a bogon in the path, so make sure we never use it.
3814 set dummy $ac_cv_prog_CC
3815 shift
3816 if test $# != 0; then
3817 # We chose a different compiler from the bogus one.
3818 # However, it has the same basename, so the bogon will be chosen
3819 # first if we set CC to just the basename; use the full file name.
3820 shift
3821 ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
3822 fi
3823 fi
3824 fi
3825 fi
3826 CC=$ac_cv_prog_CC
3827 if test -n "$CC"; then
3828 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
3829 $as_echo "$CC" >&6; }
3830 else
3831 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3832 $as_echo "no" >&6; }
3833 fi
3834
3835
3836 fi
3837 if test -z "$CC"; then
3838 if test -n "$ac_tool_prefix"; then
3839 for ac_prog in cl.exe
3840 do
3841 # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
3842 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
3843 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
3844 $as_echo_n "checking for $ac_word... " >&6; }
3845 if test "${ac_cv_prog_CC+set}" = set; then :
3846 $as_echo_n "(cached) " >&6
3847 else
3848 if test -n "$CC"; then
3849 ac_cv_prog_CC="$CC" # Let the user override the test.
3850 else
3851 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3852 for as_dir in $PATH
3853 do
3854 IFS=$as_save_IFS
3855 test -z "$as_dir" && as_dir=.
3856 for ac_exec_ext in '' $ac_executable_extensions; do
3857 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
3858 ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
3859 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3860 break 2
3861 fi
3862 done
3863 done
3864 IFS=$as_save_IFS
3865
3866 fi
3867 fi
3868 CC=$ac_cv_prog_CC
3869 if test -n "$CC"; then
3870 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
3871 $as_echo "$CC" >&6; }
3872 else
3873 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3874 $as_echo "no" >&6; }
3875 fi
3876
3877
3878 test -n "$CC" && break
3879 done
3880 fi
3881 if test -z "$CC"; then
3882 ac_ct_CC=$CC
3883 for ac_prog in cl.exe
3884 do
3885 # Extract the first word of "$ac_prog", so it can be a program name with args.
3886 set dummy $ac_prog; ac_word=$2
3887 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
3888 $as_echo_n "checking for $ac_word... " >&6; }
3889 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
3890 $as_echo_n "(cached) " >&6
3891 else
3892 if test -n "$ac_ct_CC"; then
3893 ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
3894 else
3895 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
3896 for as_dir in $PATH
3897 do
3898 IFS=$as_save_IFS
3899 test -z "$as_dir" && as_dir=.
3900 for ac_exec_ext in '' $ac_executable_extensions; do
3901 if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
3902 ac_cv_prog_ac_ct_CC="$ac_prog"
3903 $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
3904 break 2
3905 fi
3906 done
3907 done
3908 IFS=$as_save_IFS
3909
3910 fi
3911 fi
3912 ac_ct_CC=$ac_cv_prog_ac_ct_CC
3913 if test -n "$ac_ct_CC"; then
3914 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
3915 $as_echo "$ac_ct_CC" >&6; }
3916 else
3917 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
3918 $as_echo "no" >&6; }
3919 fi
3920
3921
3922 test -n "$ac_ct_CC" && break
3923 done
3924
3925 if test "x$ac_ct_CC" = x; then
3926 CC=""
3927 else
3928 case $cross_compiling:$ac_tool_warned in
3929 yes:)
3930 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
3931 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
3932 ac_tool_warned=yes ;;
3933 esac
3934 CC=$ac_ct_CC
3935 fi
3936 fi
3937
3938 fi
3939
3940
3941 test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
3942 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
3943 as_fn_error "no acceptable C compiler found in \$PATH
3944 See \`config.log' for more details." "$LINENO" 5; }
3945
3946 # Provide some information about the compiler.
3947 $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
3948 set X $ac_compile
3949 ac_compiler=$2
3950 for ac_option in --version -v -V -qversion; do
3951 { { ac_try="$ac_compiler $ac_option >&5"
3952 case "(($ac_try" in
3953 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3954 *) ac_try_echo=$ac_try;;
3955 esac
3956 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
3957 $as_echo "$ac_try_echo"; } >&5
3958 (eval "$ac_compiler $ac_option >&5") 2>conftest.err
3959 ac_status=$?
3960 if test -s conftest.err; then
3961 sed '10a\
3962 ... rest of stderr output deleted ...
3963 10q' conftest.err >conftest.er1
3964 cat conftest.er1 >&5
3965 fi
3966 rm -f conftest.er1 conftest.err
3967 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
3968 test $ac_status = 0; }
3969 done
3970
3971 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
3972 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
3973 if test "${ac_cv_c_compiler_gnu+set}" = set; then :
3974 $as_echo_n "(cached) " >&6
3975 else
3976 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3977 /* end confdefs.h. */
3978
3979 int
3980 main ()
3981 {
3982 #ifndef __GNUC__
3983 choke me
3984 #endif
3985
3986 ;
3987 return 0;
3988 }
3989 _ACEOF
3990 if ac_fn_c_try_compile "$LINENO"; then :
3991 ac_compiler_gnu=yes
3992 else
3993 ac_compiler_gnu=no
3994 fi
3995 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
3996 ac_cv_c_compiler_gnu=$ac_compiler_gnu
3997
3998 fi
3999 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
4000 $as_echo "$ac_cv_c_compiler_gnu" >&6; }
4001 if test $ac_compiler_gnu = yes; then
4002 GCC=yes
4003 else
4004 GCC=
4005 fi
4006 ac_test_CFLAGS=${CFLAGS+set}
4007 ac_save_CFLAGS=$CFLAGS
4008 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
4009 $as_echo_n "checking whether $CC accepts -g... " >&6; }
4010 if test "${ac_cv_prog_cc_g+set}" = set; then :
4011 $as_echo_n "(cached) " >&6
4012 else
4013 ac_save_c_werror_flag=$ac_c_werror_flag
4014 ac_c_werror_flag=yes
4015 ac_cv_prog_cc_g=no
4016 CFLAGS="-g"
4017 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4018 /* end confdefs.h. */
4019
4020 int
4021 main ()
4022 {
4023
4024 ;
4025 return 0;
4026 }
4027 _ACEOF
4028 if ac_fn_c_try_compile "$LINENO"; then :
4029 ac_cv_prog_cc_g=yes
4030 else
4031 CFLAGS=""
4032 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4033 /* end confdefs.h. */
4034
4035 int
4036 main ()
4037 {
4038
4039 ;
4040 return 0;
4041 }
4042 _ACEOF
4043 if ac_fn_c_try_compile "$LINENO"; then :
4044
4045 else
4046 ac_c_werror_flag=$ac_save_c_werror_flag
4047 CFLAGS="-g"
4048 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4049 /* end confdefs.h. */
4050
4051 int
4052 main ()
4053 {
4054
4055 ;
4056 return 0;
4057 }
4058 _ACEOF
4059 if ac_fn_c_try_compile "$LINENO"; then :
4060 ac_cv_prog_cc_g=yes
4061 fi
4062 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4063 fi
4064 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4065 fi
4066 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4067 ac_c_werror_flag=$ac_save_c_werror_flag
4068 fi
4069 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
4070 $as_echo "$ac_cv_prog_cc_g" >&6; }
4071 if test "$ac_test_CFLAGS" = set; then
4072 CFLAGS=$ac_save_CFLAGS
4073 elif test $ac_cv_prog_cc_g = yes; then
4074 if test "$GCC" = yes; then
4075 CFLAGS="-g -O2"
4076 else
4077 CFLAGS="-g"
4078 fi
4079 else
4080 if test "$GCC" = yes; then
4081 CFLAGS="-O2"
4082 else
4083 CFLAGS=
4084 fi
4085 fi
4086 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
4087 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
4088 if test "${ac_cv_prog_cc_c89+set}" = set; then :
4089 $as_echo_n "(cached) " >&6
4090 else
4091 ac_cv_prog_cc_c89=no
4092 ac_save_CC=$CC
4093 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4094 /* end confdefs.h. */
4095 #include <stdarg.h>
4096 #include <stdio.h>
4097 #include <sys/types.h>
4098 #include <sys/stat.h>
4099 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
4100 struct buf { int x; };
4101 FILE * (*rcsopen) (struct buf *, struct stat *, int);
4102 static char *e (p, i)
4103 char **p;
4104 int i;
4105 {
4106 return p[i];
4107 }
4108 static char *f (char * (*g) (char **, int), char **p, ...)
4109 {
4110 char *s;
4111 va_list v;
4112 va_start (v,p);
4113 s = g (p, va_arg (v,int));
4114 va_end (v);
4115 return s;
4116 }
4117
4118 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
4119 function prototypes and stuff, but not '\xHH' hex character constants.
4120 These don't provoke an error unfortunately, instead are silently treated
4121 as 'x'. The following induces an error, until -std is added to get
4122 proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
4123 array size at least. It's necessary to write '\x00'==0 to get something
4124 that's true only with -std. */
4125 int osf4_cc_array ['\x00' == 0 ? 1 : -1];
4126
4127 /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
4128 inside strings and character constants. */
4129 #define FOO(x) 'x'
4130 int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
4131
4132 int test (int i, double x);
4133 struct s1 {int (*f) (int a);};
4134 struct s2 {int (*f) (double a);};
4135 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
4136 int argc;
4137 char **argv;
4138 int
4139 main ()
4140 {
4141 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
4142 ;
4143 return 0;
4144 }
4145 _ACEOF
4146 for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
4147 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
4148 do
4149 CC="$ac_save_CC $ac_arg"
4150 if ac_fn_c_try_compile "$LINENO"; then :
4151 ac_cv_prog_cc_c89=$ac_arg
4152 fi
4153 rm -f core conftest.err conftest.$ac_objext
4154 test "x$ac_cv_prog_cc_c89" != "xno" && break
4155 done
4156 rm -f conftest.$ac_ext
4157 CC=$ac_save_CC
4158
4159 fi
4160 # AC_CACHE_VAL
4161 case "x$ac_cv_prog_cc_c89" in
4162 x)
4163 { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
4164 $as_echo "none needed" >&6; } ;;
4165 xno)
4166 { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
4167 $as_echo "unsupported" >&6; } ;;
4168 *)
4169 CC="$CC $ac_cv_prog_cc_c89"
4170 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
4171 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
4172 esac
4173 if test "x$ac_cv_prog_cc_c89" != xno; then :
4174
4175 fi
4176
4177 ac_ext=c
4178 ac_cpp='$CPP $CPPFLAGS'
4179 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
4180 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
4181 ac_compiler_gnu=$ac_cv_c_compiler_gnu
4182
4183 depcc="$CC" am_compiler_list=
4184
4185 { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
4186 $as_echo_n "checking dependency style of $depcc... " >&6; }
4187 if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
4188 $as_echo_n "(cached) " >&6
4189 else
4190 if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
4191 # We make a subdir and do the tests there. Otherwise we can end up
4192 # making bogus files that we don't know about and never remove. For
4193 # instance it was reported that on HP-UX the gcc test will end up
4194 # making a dummy file named `D' -- because `-MD' means `put the output
4195 # in D'.
4196 mkdir conftest.dir
4197 # Copy depcomp to subdir because otherwise we won't find it if we're
4198 # using a relative directory.
4199 cp "$am_depcomp" conftest.dir
4200 cd conftest.dir
4201 # We will build objects and dependencies in a subdirectory because
4202 # it helps to detect inapplicable dependency modes. For instance
4203 # both Tru64's cc and ICC support -MD to output dependencies as a
4204 # side effect of compilation, but ICC will put the dependencies in
4205 # the current directory while Tru64 will put them in the object
4206 # directory.
4207 mkdir sub
4208
4209 am_cv_CC_dependencies_compiler_type=none
4210 if test "$am_compiler_list" = ""; then
4211 am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
4212 fi
4213 am__universal=false
4214 case " $depcc " in #(
4215 *\ -arch\ *\ -arch\ *) am__universal=true ;;
4216 esac
4217
4218 for depmode in $am_compiler_list; do
4219 # Setup a source with many dependencies, because some compilers
4220 # like to wrap large dependency lists on column 80 (with \), and
4221 # we should not choose a depcomp mode which is confused by this.
4222 #
4223 # We need to recreate these files for each test, as the compiler may
4224 # overwrite some of them when testing with obscure command lines.
4225 # This happens at least with the AIX C compiler.
4226 : > sub/conftest.c
4227 for i in 1 2 3 4 5 6; do
4228 echo '#include "conftst'$i'.h"' >> sub/conftest.c
4229 # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
4230 # Solaris 8's {/usr,}/bin/sh.
4231 touch sub/conftst$i.h
4232 done
4233 echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
4234
4235 # We check with `-c' and `-o' for the sake of the "dashmstdout"
4236 # mode. It turns out that the SunPro C++ compiler does not properly
4237 # handle `-M -o', and we need to detect this. Also, some Intel
4238 # versions had trouble with output in subdirs
4239 am__obj=sub/conftest.${OBJEXT-o}
4240 am__minus_obj="-o $am__obj"
4241 case $depmode in
4242 gcc)
4243 # This depmode causes a compiler race in universal mode.
4244 test "$am__universal" = false || continue
4245 ;;
4246 nosideeffect)
4247 # after this tag, mechanisms are not by side-effect, so they'll
4248 # only be used when explicitly requested
4249 if test "x$enable_dependency_tracking" = xyes; then
4250 continue
4251 else
4252 break
4253 fi
4254 ;;
4255 msvisualcpp | msvcmsys)
4256 # This compiler won't grok `-c -o', but also, the minuso test has
4257 # not run yet. These depmodes are late enough in the game, and
4258 # so weak that their functioning should not be impacted.
4259 am__obj=conftest.${OBJEXT-o}
4260 am__minus_obj=
4261 ;;
4262 none) break ;;
4263 esac
4264 if depmode=$depmode \
4265 source=sub/conftest.c object=$am__obj \
4266 depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
4267 $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
4268 >/dev/null 2>conftest.err &&
4269 grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
4270 grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
4271 grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
4272 ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
4273 # icc doesn't choke on unknown options, it will just issue warnings
4274 # or remarks (even with -Werror). So we grep stderr for any message
4275 # that says an option was ignored or not supported.
4276 # When given -MP, icc 7.0 and 7.1 complain thusly:
4277 # icc: Command line warning: ignoring option '-M'; no argument required
4278 # The diagnosis changed in icc 8.0:
4279 # icc: Command line remark: option '-MP' not supported
4280 if (grep 'ignoring option' conftest.err ||
4281 grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
4282 am_cv_CC_dependencies_compiler_type=$depmode
4283 break
4284 fi
4285 fi
4286 done
4287
4288 cd ..
4289 rm -rf conftest.dir
4290 else
4291 am_cv_CC_dependencies_compiler_type=none
4292 fi
4293
4294 fi
4295 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
4296 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
4297 CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
4298
4299 if
4300 test "x$enable_dependency_tracking" != xno \
4301 && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
4302 am__fastdepCC_TRUE=
4303 am__fastdepCC_FALSE='#'
4304 else
4305 am__fastdepCC_TRUE='#'
4306 am__fastdepCC_FALSE=
4307 fi
4308
4309
4310
4311
4312 DEFAULT_INSTALL_PREFIX="/usr/local"
4313 STANDARD_PREFIXES="/usr /usr/local /opt /local"
4314
4315
4316
4317 # Check whether --with-libdir was given.
4318 if test "${with_libdir+set}" = set; then :
4319 withval=$with_libdir; LIBDIR=$with_libdir
4320 else
4321 LIBDIR=lib
4322
4323 fi
4324
4325
4326 # Check whether --enable-rpath was given.
4327 if test "${enable_rpath+set}" = set; then :
4328 enableval=$enable_rpath; BEAN_RPATH=no
4329 else
4330 BEAN_RPATH=yes
4331
4332 fi
4333
4334
4335 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports -R" >&5
4336 $as_echo_n "checking if compiler supports -R... " >&6; }
4337 if test "${bt_cv_cc_dashr+set}" = set; then :
4338 $as_echo_n "(cached) " >&6
4339 else
4340
4341 SAVE_LIBS=$LIBS
4342 LIBS="-R /usr/$LIBDIR $LIBS"
4343 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4344 /* end confdefs.h. */
4345
4346 int
4347 main ()
4348 {
4349
4350 ;
4351 return 0;
4352 }
4353 _ACEOF
4354 if ac_fn_c_try_link "$LINENO"; then :
4355 bt_cv_cc_dashr=yes
4356 else
4357 bt_cv_cc_dashr=no
4358 fi
4359 rm -f core conftest.err conftest.$ac_objext \
4360 conftest$ac_exeext conftest.$ac_ext
4361 LIBS=$SAVE_LIBS
4362 fi
4363
4364 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bt_cv_cc_dashr" >&5
4365 $as_echo "$bt_cv_cc_dashr" >&6; }
4366 if test $bt_cv_cc_dashr = "yes"; then
4367 ld_runpath_switch=-R
4368 else
4369 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports -Wl,-rpath," >&5
4370 $as_echo_n "checking if compiler supports -Wl,-rpath,... " >&6; }
4371 if test "${bt_cv_cc_rpath+set}" = set; then :
4372 $as_echo_n "(cached) " >&6
4373 else
4374
4375 SAVE_LIBS=$LIBS
4376 LIBS="-Wl,-rpath,/usr/$LIBDIR $LIBS"
4377 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4378 /* end confdefs.h. */
4379
4380 int
4381 main ()
4382 {
4383
4384 ;
4385 return 0;
4386 }
4387 _ACEOF
4388 if ac_fn_c_try_link "$LINENO"; then :
4389 bt_cv_cc_rpath=yes
4390 else
4391 bt_cv_cc_rpath=no
4392 fi
4393 rm -f core conftest.err conftest.$ac_objext \
4394 conftest$ac_exeext conftest.$ac_ext
4395 LIBS=$SAVE_LIBS
4396 fi
4397
4398 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $bt_cv_cc_rpath" >&5
4399 $as_echo "$bt_cv_cc_rpath" >&6; }
4400 if test $bt_cv_cc_rpath = "yes"; then
4401 ld_runpath_switch=-Wl,-rpath,
4402 else
4403 ld_runpath_switch=-L
4404 fi
4405 fi
4406 if test "$BEAN_RPATH" = "no"; then
4407 ld_runpath_switch=
4408 fi
4409
4410
4411 # Check whether --with-event was given.
4412 if test "${with_event+set}" = set; then :
4413 withval=$with_event;
4414 else
4415 with_event=yes
4416
4417 fi
4418
4419
4420 if test "x$with_event" = "xno"; then
4421 as_fn_error "can't continue without libevent" "$LINENO" 5
4422 else
4423 { $as_echo "$as_me:${as_lineno-$LINENO}: checking libevent install prefix" >&5
4424 $as_echo_n "checking libevent install prefix... " >&6; }
4425
4426 if test "x$with_event" = "xyes"; then
4427 for i in `echo "$STANDARD_PREFIXES"`; do
4428 if test -f "$i/include/event.h"; then
4429 LIBEVENT_DIR="$i"
4430 break;
4431 fi
4432 done
4433 else
4434 if test -f "$with_event/include/event.h"; then
4435 LIBEVENT_DIR="$with_event"
4436 break;
4437 else
4438 as_fn_error "Can't find libevent headers under $with_event directory" "$LINENO" 5
4439 fi
4440 fi
4441
4442 if test "x$LIBEVENT_DIR" = "x"; then
4443 as_fn_error "Unable to locate libevent headers, please use --with-event=<DIR>" "$LINENO" 5
4444 fi
4445
4446 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBEVENT_DIR" >&5
4447 $as_echo "$LIBEVENT_DIR" >&6; }
4448 LDFLAGS="$LDFLAGS -L$LIBEVENT_DIR/$LIBDIR"
4449 CFLAGS="$CFLAGS -I$LIBEVENT_DIR/include"
4450 LIBS="$LIBS -levent"
4451
4452 for ac_func in posix_fallocate
4453 do :
4454 ac_fn_c_check_func "$LINENO" "posix_fallocate" "ac_cv_func_posix_fallocate"
4455 if test "x$ac_cv_func_posix_fallocate" = x""yes; then :
4456 cat >>confdefs.h <<_ACEOF
4457 #define HAVE_POSIX_FALLOCATE 1
4458 _ACEOF
4459
4460 fi
4461 done
4462
4463 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fdatasync" >&5
4464 $as_echo_n "checking for fdatasync... " >&6; }
4465 if test "${ac_cv_func_fdatasync+set}" = set; then :
4466 $as_echo_n "(cached) " >&6
4467 else
4468
4469 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4470 /* end confdefs.h. */
4471
4472 #include <unistd.h>
4473
4474 int
4475 main ()
4476 {
4477
4478 fdatasync(4);
4479
4480 ;
4481 return 0;
4482 }
4483 _ACEOF
4484 if ac_fn_c_try_compile "$LINENO"; then :
4485 ac_cv_func_fdatasync=yes
4486 else
4487 ac_cv_func_fdatasync=no
4488 fi
4489 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4490
4491 fi
4492 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_fdatasync" >&5
4493 $as_echo "$ac_cv_func_fdatasync" >&6; }
4494 if test "x${ac_cv_func_fdatasync}" = "xyes"; then :
4495
4496 $as_echo "#define HAVE_FDATASYNC 1" >>confdefs.h
4497
4498 fi
4499
4500 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bind in -lsocket" >&5
4501 $as_echo_n "checking for bind in -lsocket... " >&6; }
4502 if test "${ac_cv_lib_socket_bind+set}" = set; then :
4503 $as_echo_n "(cached) " >&6
4504 else
4505 ac_check_lib_save_LIBS=$LIBS
4506 LIBS="-lsocket $LIBS"
4507 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4508 /* end confdefs.h. */
4509
4510 /* Override any GCC internal prototype to avoid an error.
4511 Use char because int might match the return type of a GCC
4512 builtin and then its argument prototype would still apply. */
4513 #ifdef __cplusplus
4514 extern "C"
4515 #endif
4516 char bind ();
4517 int
4518 main ()
4519 {
4520 return bind ();
4521 ;
4522 return 0;
4523 }
4524 _ACEOF
4525 if ac_fn_c_try_link "$LINENO"; then :
4526 ac_cv_lib_socket_bind=yes
4527 else
4528 ac_cv_lib_socket_bind=no
4529 fi
4530 rm -f core conftest.err conftest.$ac_objext \
4531 conftest$ac_exeext conftest.$ac_ext
4532 LIBS=$ac_check_lib_save_LIBS
4533 fi
4534 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_bind" >&5
4535 $as_echo "$ac_cv_lib_socket_bind" >&6; }
4536 if test "x$ac_cv_lib_socket_bind" = x""yes; then :
4537
4538 LIBS="$LIBS -lsocket"
4539
4540 fi
4541
4542
4543 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inet_aton in -lnsl" >&5
4544 $as_echo_n "checking for inet_aton in -lnsl... " >&6; }
4545 if test "${ac_cv_lib_nsl_inet_aton+set}" = set; then :
4546 $as_echo_n "(cached) " >&6
4547 else
4548 ac_check_lib_save_LIBS=$LIBS
4549 LIBS="-lnsl $LIBS"
4550 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4551 /* end confdefs.h. */
4552
4553 /* Override any GCC internal prototype to avoid an error.
4554 Use char because int might match the return type of a GCC
4555 builtin and then its argument prototype would still apply. */
4556 #ifdef __cplusplus
4557 extern "C"
4558 #endif
4559 char inet_aton ();
4560 int
4561 main ()
4562 {
4563 return inet_aton ();
4564 ;
4565 return 0;
4566 }
4567 _ACEOF
4568 if ac_fn_c_try_link "$LINENO"; then :
4569 ac_cv_lib_nsl_inet_aton=yes
4570 else
4571 ac_cv_lib_nsl_inet_aton=no
4572 fi
4573 rm -f core conftest.err conftest.$ac_objext \
4574 conftest$ac_exeext conftest.$ac_ext
4575 LIBS=$ac_check_lib_save_LIBS
4576 fi
4577 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_inet_aton" >&5
4578 $as_echo "$ac_cv_lib_nsl_inet_aton" >&6; }
4579 if test "x$ac_cv_lib_nsl_inet_aton" = x""yes; then :
4580
4581 LIBS="$LIBS -lnsl"
4582
4583 fi
4584
4585
4586 if test "$BEAN_RPATH" != "no"; then
4587 LDFLAGS="$LDFLAGS $ld_runpath_switch$LIBEVENT_DIR/$LIBDIR"
4588 fi
4589
4590 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for event_get_version in -levent" >&5
4591 $as_echo_n "checking for event_get_version in -levent... " >&6; }
4592 if test "${ac_cv_lib_event_event_get_version+set}" = set; then :
4593 $as_echo_n "(cached) " >&6
4594 else
4595 ac_check_lib_save_LIBS=$LIBS
4596 LIBS="-levent $LIBS"
4597 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4598 /* end confdefs.h. */
4599
4600 /* Override any GCC internal prototype to avoid an error.
4601 Use char because int might match the return type of a GCC
4602 builtin and then its argument prototype would still apply. */
4603 #ifdef __cplusplus
4604 extern "C"
4605 #endif
4606 char event_get_version ();
4607 int
4608 main ()
4609 {
4610 return event_get_version ();
4611 ;
4612 return 0;
4613 }
4614 _ACEOF
4615 if ac_fn_c_try_link "$LINENO"; then :
4616 ac_cv_lib_event_event_get_version=yes
4617 else
4618 ac_cv_lib_event_event_get_version=no
4619 fi
4620 rm -f core conftest.err conftest.$ac_objext \
4621 conftest$ac_exeext conftest.$ac_ext
4622 LIBS=$ac_check_lib_save_LIBS
4623 fi
4624 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_event_event_get_version" >&5
4625 $as_echo "$ac_cv_lib_event_event_get_version" >&6; }
4626 if test "x$ac_cv_lib_event_event_get_version" = x""yes; then :
4627 cat >>confdefs.h <<_ACEOF
4628 #define HAVE_LIBEVENT 1
4629 _ACEOF
4630
4631 LIBS="-levent $LIBS"
4632
4633 else
4634
4635 as_fn_error "event_get_version() is missing, check config.log for more details" "$LINENO" 5
4636
4637 fi
4638
4639
4640 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for event_reinit in -levent" >&5
4641 $as_echo_n "checking for event_reinit in -levent... " >&6; }
4642 if test "${ac_cv_lib_event_event_reinit+set}" = set; then :
4643 $as_echo_n "(cached) " >&6
4644 else
4645 ac_check_lib_save_LIBS=$LIBS
4646 LIBS="-levent $LIBS"
4647 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4648 /* end confdefs.h. */
4649
4650 /* Override any GCC internal prototype to avoid an error.
4651 Use char because int might match the return type of a GCC
4652 builtin and then its argument prototype would still apply. */
4653 #ifdef __cplusplus
4654 extern "C"
4655 #endif
4656 char event_reinit ();
4657 int
4658 main ()
4659 {
4660 return event_reinit ();
4661 ;
4662 return 0;
4663 }
4664 _ACEOF
4665 if ac_fn_c_try_link "$LINENO"; then :
4666 ac_cv_lib_event_event_reinit=yes
4667 else
4668 ac_cv_lib_event_event_reinit=no
4669 fi
4670 rm -f core conftest.err conftest.$ac_objext \
4671 conftest$ac_exeext conftest.$ac_ext
4672 LIBS=$ac_check_lib_save_LIBS
4673 fi
4674 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_event_event_reinit" >&5
4675 $as_echo "$ac_cv_lib_event_event_reinit" >&6; }
4676 if test "x$ac_cv_lib_event_event_reinit" = x""yes; then :
4677 cat >>confdefs.h <<_ACEOF
4678 #define HAVE_LIBEVENT 1
4679 _ACEOF
4680
4681 LIBS="-levent $LIBS"
4682
4683 else
4684
4685 as_fn_error "beanstalkd requires libevent version 1.4.1 or later." "$LINENO" 5
4686
4687 fi
4688
4689
4690 if test -f "$LIBEVENT_DIR/$LIBDIR/libevent.so"; then
4691 LIBEVENT="$LIBEVENT_DIR/$LIBDIR/libevent.so";
4692 else
4693 if test -f "$LIBEVENT_DIR/lib/libevent.so"; then
4694 LIBEVENT="$LIBEVENT_DIR/lib/libevent.so";
4695 else
4696 if test -f "$LIBEVENT_DIR/lib64/libevent.so"; then
4697 LIBEVENT="$LIBEVENT_DIR/lib64/libevent.so";
4698 fi
4699 fi
4700 fi
4701 fi
4702
4703
4704 # Check whether --enable-debug was given.
4705 if test "${enable_debug+set}" = set; then :
4706 enableval=$enable_debug;
4707 if test x"$enableval" = xyes ; then
4708 debug="yes"
4709 else
4710 debug="no"
4711 fi
4712
4713
4714 fi
4715
4716
4717 if test x"$debug" = xyes ; then
4718
4719 $as_echo "#define BEAN_DEBUG /**/" >>confdefs.h
4720
4721
4722 if test x"$GCC" = xyes; then
4723
4724 CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9s]*//g'`
4725 CFLAGS=`echo "$CFLAGS" | sed -e 's/-g[0-2]\? //g'`
4726
4727 CFLAGS="$CFLAGS -g3 -Wall -O0"
4728 fi
4729
4730 INSTALL_STRIP_FLAG=""
4731 else
4732 INSTALL_STRIP_FLAG="-s"
4733 fi
4734
4735 # Checks for typedefs, structures, and compiler characteristics.
4736 ac_ext=c
4737 ac_cpp='$CPP $CPPFLAGS'
4738 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
4739 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
4740 ac_compiler_gnu=$ac_cv_c_compiler_gnu
4741 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
4742 $as_echo_n "checking how to run the C preprocessor... " >&6; }
4743 # On Suns, sometimes $CPP names a directory.
4744 if test -n "$CPP" && test -d "$CPP"; then
4745 CPP=
4746 fi
4747 if test -z "$CPP"; then
4748 if test "${ac_cv_prog_CPP+set}" = set; then :
4749 $as_echo_n "(cached) " >&6
4750 else
4751 # Double quotes because CPP needs to be expanded
4752 for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
4753 do
4754 ac_preproc_ok=false
4755 for ac_c_preproc_warn_flag in '' yes
4756 do
4757 # Use a header file that comes with gcc, so configuring glibc
4758 # with a fresh cross-compiler works.
4759 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
4760 # <limits.h> exists even on freestanding compilers.
4761 # On the NeXT, cc -E runs the code through the compiler's parser,
4762 # not just through cpp. "Syntax error" is here to catch this case.
4763 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4764 /* end confdefs.h. */
4765 #ifdef __STDC__
4766 # include <limits.h>
4767 #else
4768 # include <assert.h>
4769 #endif
4770 Syntax error
4771 _ACEOF
4772 if ac_fn_c_try_cpp "$LINENO"; then :
4773
4774 else
4775 # Broken: fails on valid input.
4776 continue
4777 fi
4778 rm -f conftest.err conftest.$ac_ext
4779
4780 # OK, works on sane cases. Now check whether nonexistent headers
4781 # can be detected and how.
4782 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4783 /* end confdefs.h. */
4784 #include <ac_nonexistent.h>
4785 _ACEOF
4786 if ac_fn_c_try_cpp "$LINENO"; then :
4787 # Broken: success on invalid input.
4788 continue
4789 else
4790 # Passes both tests.
4791 ac_preproc_ok=:
4792 break
4793 fi
4794 rm -f conftest.err conftest.$ac_ext
4795
4796 done
4797 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
4798 rm -f conftest.err conftest.$ac_ext
4799 if $ac_preproc_ok; then :
4800 break
4801 fi
4802
4803 done
4804 ac_cv_prog_CPP=$CPP
4805
4806 fi
4807 CPP=$ac_cv_prog_CPP
4808 else
4809 ac_cv_prog_CPP=$CPP
4810 fi
4811 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
4812 $as_echo "$CPP" >&6; }
4813 ac_preproc_ok=false
4814 for ac_c_preproc_warn_flag in '' yes
4815 do
4816 # Use a header file that comes with gcc, so configuring glibc
4817 # with a fresh cross-compiler works.
4818 # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
4819 # <limits.h> exists even on freestanding compilers.
4820 # On the NeXT, cc -E runs the code through the compiler's parser,
4821 # not just through cpp. "Syntax error" is here to catch this case.
4822 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4823 /* end confdefs.h. */
4824 #ifdef __STDC__
4825 # include <limits.h>
4826 #else
4827 # include <assert.h>
4828 #endif
4829 Syntax error
4830 _ACEOF
4831 if ac_fn_c_try_cpp "$LINENO"; then :
4832
4833 else
4834 # Broken: fails on valid input.
4835 continue
4836 fi
4837 rm -f conftest.err conftest.$ac_ext
4838
4839 # OK, works on sane cases. Now check whether nonexistent headers
4840 # can be detected and how.
4841 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4842 /* end confdefs.h. */
4843 #include <ac_nonexistent.h>
4844 _ACEOF
4845 if ac_fn_c_try_cpp "$LINENO"; then :
4846 # Broken: success on invalid input.
4847 continue
4848 else
4849 # Passes both tests.
4850 ac_preproc_ok=:
4851 break
4852 fi
4853 rm -f conftest.err conftest.$ac_ext
4854
4855 done
4856 # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
4857 rm -f conftest.err conftest.$ac_ext
4858 if $ac_preproc_ok; then :
4859
4860 else
4861 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
4862 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
4863 as_fn_error "C preprocessor \"$CPP\" fails sanity check
4864 See \`config.log' for more details." "$LINENO" 5; }
4865 fi
4866
4867 ac_ext=c
4868 ac_cpp='$CPP $CPPFLAGS'
4869 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
4870 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
4871 ac_compiler_gnu=$ac_cv_c_compiler_gnu
4872
4873
4874 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
4875 $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
4876 if test "${ac_cv_path_GREP+set}" = set; then :
4877 $as_echo_n "(cached) " >&6
4878 else
4879 if test -z "$GREP"; then
4880 ac_path_GREP_found=false
4881 # Loop through the user's path and test for each of PROGNAME-LIST
4882 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4883 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
4884 do
4885 IFS=$as_save_IFS
4886 test -z "$as_dir" && as_dir=.
4887 for ac_prog in grep ggrep; do
4888 for ac_exec_ext in '' $ac_executable_extensions; do
4889 ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
4890 { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
4891 # Check for GNU ac_path_GREP and select it if it is found.
4892 # Check for GNU $ac_path_GREP
4893 case `"$ac_path_GREP" --version 2>&1` in
4894 *GNU*)
4895 ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
4896 *)
4897 ac_count=0
4898 $as_echo_n 0123456789 >"conftest.in"
4899 while :
4900 do
4901 cat "conftest.in" "conftest.in" >"conftest.tmp"
4902 mv "conftest.tmp" "conftest.in"
4903 cp "conftest.in" "conftest.nl"
4904 $as_echo 'GREP' >> "conftest.nl"
4905 "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
4906 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
4907 as_fn_arith $ac_count + 1 && ac_count=$as_val
4908 if test $ac_count -gt ${ac_path_GREP_max-0}; then
4909 # Best one so far, save it but keep looking for a better one
4910 ac_cv_path_GREP="$ac_path_GREP"
4911 ac_path_GREP_max=$ac_count
4912 fi
4913 # 10*(2^10) chars as input seems more than enough
4914 test $ac_count -gt 10 && break
4915 done
4916 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
4917 esac
4918
4919 $ac_path_GREP_found && break 3
4920 done
4921 done
4922 done
4923 IFS=$as_save_IFS
4924 if test -z "$ac_cv_path_GREP"; then
4925 as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
4926 fi
4927 else
4928 ac_cv_path_GREP=$GREP
4929 fi
4930
4931 fi
4932 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
4933 $as_echo "$ac_cv_path_GREP" >&6; }
4934 GREP="$ac_cv_path_GREP"
4935
4936
4937 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
4938 $as_echo_n "checking for egrep... " >&6; }
4939 if test "${ac_cv_path_EGREP+set}" = set; then :
4940 $as_echo_n "(cached) " >&6
4941 else
4942 if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
4943 then ac_cv_path_EGREP="$GREP -E"
4944 else
4945 if test -z "$EGREP"; then
4946 ac_path_EGREP_found=false
4947 # Loop through the user's path and test for each of PROGNAME-LIST
4948 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
4949 for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
4950 do
4951 IFS=$as_save_IFS
4952 test -z "$as_dir" && as_dir=.
4953 for ac_prog in egrep; do
4954 for ac_exec_ext in '' $ac_executable_extensions; do
4955 ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
4956 { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
4957 # Check for GNU ac_path_EGREP and select it if it is found.
4958 # Check for GNU $ac_path_EGREP
4959 case `"$ac_path_EGREP" --version 2>&1` in
4960 *GNU*)
4961 ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
4962 *)
4963 ac_count=0
4964 $as_echo_n 0123456789 >"conftest.in"
4965 while :
4966 do
4967 cat "conftest.in" "conftest.in" >"conftest.tmp"
4968 mv "conftest.tmp" "conftest.in"
4969 cp "conftest.in" "conftest.nl"
4970 $as_echo 'EGREP' >> "conftest.nl"
4971 "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
4972 diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
4973 as_fn_arith $ac_count + 1 && ac_count=$as_val
4974 if test $ac_count -gt ${ac_path_EGREP_max-0}; then
4975 # Best one so far, save it but keep looking for a better one
4976 ac_cv_path_EGREP="$ac_path_EGREP"
4977 ac_path_EGREP_max=$ac_count
4978 fi
4979 # 10*(2^10) chars as input seems more than enough
4980 test $ac_count -gt 10 && break
4981 done
4982 rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
4983 esac
4984
4985 $ac_path_EGREP_found && break 3
4986 done
4987 done
4988 done
4989 IFS=$as_save_IFS
4990 if test -z "$ac_cv_path_EGREP"; then
4991 as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
4992 fi
4993 else
4994 ac_cv_path_EGREP=$EGREP
4995 fi
4996
4997 fi
4998 fi
4999 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
5000 $as_echo "$ac_cv_path_EGREP" >&6; }
5001 EGREP="$ac_cv_path_EGREP"
5002
5003
5004 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
5005 $as_echo_n "checking for ANSI C header files... " >&6; }
5006 if test "${ac_cv_header_stdc+set}" = set; then :
5007 $as_echo_n "(cached) " >&6
5008 else
5009 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5010 /* end confdefs.h. */
5011 #include <stdlib.h>
5012 #include <stdarg.h>
5013 #include <string.h>
5014 #include <float.h>
5015
5016 int
5017 main ()
5018 {
5019
5020 ;
5021 return 0;
5022 }
5023 _ACEOF
5024 if ac_fn_c_try_compile "$LINENO"; then :
5025 ac_cv_header_stdc=yes
5026 else
5027 ac_cv_header_stdc=no
5028 fi
5029 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5030
5031 if test $ac_cv_header_stdc = yes; then
5032 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
5033 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5034 /* end confdefs.h. */
5035 #include <string.h>
5036
5037 _ACEOF
5038 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
5039 $EGREP "memchr" >/dev/null 2>&1; then :
5040
5041 else
5042 ac_cv_header_stdc=no
5043 fi
5044 rm -f conftest*
5045
5046 fi
5047
5048 if test $ac_cv_header_stdc = yes; then
5049 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
5050 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5051 /* end confdefs.h. */
5052 #include <stdlib.h>
5053
5054 _ACEOF
5055 if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
5056 $EGREP "free" >/dev/null 2>&1; then :
5057
5058 else
5059 ac_cv_header_stdc=no
5060 fi
5061 rm -f conftest*
5062
5063 fi
5064
5065 if test $ac_cv_header_stdc = yes; then
5066 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
5067 if test "$cross_compiling" = yes; then :
5068 :
5069 else
5070 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5071 /* end confdefs.h. */
5072 #include <ctype.h>
5073 #include <stdlib.h>
5074 #if ((' ' & 0x0FF) == 0x020)
5075 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
5076 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
5077 #else
5078 # define ISLOWER(c) \
5079 (('a' <= (c) && (c) <= 'i') \
5080 || ('j' <= (c) && (c) <= 'r') \
5081 || ('s' <= (c) && (c) <= 'z'))
5082 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
5083 #endif
5084
5085 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
5086 int
5087 main ()
5088 {
5089 int i;
5090 for (i = 0; i < 256; i++)
5091 if (XOR (islower (i), ISLOWER (i))
5092 || toupper (i) != TOUPPER (i))
5093 return 2;
5094 return 0;
5095 }
5096 _ACEOF
5097 if ac_fn_c_try_run "$LINENO"; then :
5098
5099 else
5100 ac_cv_header_stdc=no
5101 fi
5102 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
5103 conftest.$ac_objext conftest.beam conftest.$ac_ext
5104 fi
5105
5106 fi
5107 fi
5108 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
5109 $as_echo "$ac_cv_header_stdc" >&6; }
5110 if test $ac_cv_header_stdc = yes; then
5111
5112 $as_echo "#define STDC_HEADERS 1" >>confdefs.h
5113
5114 fi
5115
5116 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
5117 for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
5118 inttypes.h stdint.h unistd.h
5119 do :
5120 as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
5121 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
5122 "
5123 eval as_val=\$$as_ac_Header
5124 if test "x$as_val" = x""yes; then :
5125 cat >>confdefs.h <<_ACEOF
5126 #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
5127 _ACEOF
5128
5129 fi
5130
5131 done
5132
5133
5134 ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t"
5135 case $ac_cv_c_uint16_t in #(
5136 no|yes) ;; #(
5137 *)
5138
5139
5140 cat >>confdefs.h <<_ACEOF
5141 #define uint16_t $ac_cv_c_uint16_t
5142 _ACEOF
5143 ;;
5144 esac
5145
5146
5147
5148
5149 ac_config_files="$ac_config_files Makefile"
5150
5151 cat >confcache <<\_ACEOF
5152 # This file is a shell script that caches the results of configure
5153 # tests run on this system so they can be shared between configure
5154 # scripts and configure runs, see configure's option --config-cache.
5155 # It is not useful on other systems. If it contains results you don't
5156 # want to keep, you may remove or edit it.
5157 #
5158 # config.status only pays attention to the cache file if you give it
5159 # the --recheck option to rerun configure.
5160 #
5161 # `ac_cv_env_foo' variables (set or unset) will be overridden when
5162 # loading this file, other *unset* `ac_cv_foo' will be assigned the
5163 # following values.
5164
5165 _ACEOF
5166
5167 # The following way of writing the cache mishandles newlines in values,
5168 # but we know of no workaround that is simple, portable, and efficient.
5169 # So, we kill variables containing newlines.
5170 # Ultrix sh set writes to stderr and can't be redirected directly,
5171 # and sets the high bit in the cache file unless we assign to the vars.
5172 (
5173 for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
5174 eval ac_val=\$$ac_var
5175 case $ac_val in #(
5176 *${as_nl}*)
5177 case $ac_var in #(
5178 *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
5179 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
5180 esac
5181 case $ac_var in #(
5182 _ | IFS | as_nl) ;; #(
5183 BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
5184 *) { eval $ac_var=; unset $ac_var;} ;;
5185 esac ;;
5186 esac
5187 done
5188
5189 (set) 2>&1 |
5190 case $as_nl`(ac_space=' '; set) 2>&1` in #(
5191 *${as_nl}ac_space=\ *)
5192 # `set' does not quote correctly, so add quotes: double-quote
5193 # substitution turns \\\\ into \\, and sed turns \\ into \.
5194 sed -n \
5195 "s/'/'\\\\''/g;
5196 s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
5197 ;; #(
5198 *)
5199 # `set' quotes correctly as required by POSIX, so do not add quotes.
5200 sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
5201 ;;
5202 esac |
5203 sort
5204 ) |
5205 sed '
5206 /^ac_cv_env_/b end
5207 t clear
5208 :clear
5209 s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
5210 t end
5211 s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
5212 :end' >>confcache
5213 if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
5214 if test -w "$cache_file"; then
5215 test "x$cache_file" != "x/dev/null" &&
5216 { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
5217 $as_echo "$as_me: updating cache $cache_file" >&6;}
5218 cat confcache >$cache_file
5219 else
5220 { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
5221 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
5222 fi
5223 fi
5224 rm -f confcache
5225
5226 test "x$prefix" = xNONE && prefix=$ac_default_prefix
5227 # Let make expand exec_prefix.
5228 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
5229
5230 DEFS=-DHAVE_CONFIG_H
5231
5232 ac_libobjs=
5233 ac_ltlibobjs=
5234 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
5235 # 1. Remove the extension, and $U if already installed.
5236 ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
5237 ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
5238 # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
5239 # will be set to the directory where LIBOBJS objects are built.
5240 as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
5241 as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
5242 done
5243 LIBOBJS=$ac_libobjs
5244
5245 LTLIBOBJS=$ac_ltlibobjs
5246
5247
5248 if test -n "$EXEEXT"; then
5249 am__EXEEXT_TRUE=
5250 am__EXEEXT_FALSE='#'
5251 else
5252 am__EXEEXT_TRUE='#'
5253 am__EXEEXT_FALSE=
5254 fi
5255
5256 if test -z "${MAINTAINER_MODE_TRUE}" && test -z "${MAINTAINER_MODE_FALSE}"; then
5257 as_fn_error "conditional \"MAINTAINER_MODE\" was never defined.
5258 Usually this means the macro was only invoked conditionally." "$LINENO" 5
5259 fi
5260 if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
5261 as_fn_error "conditional \"AMDEP\" was never defined.
5262 Usually this means the macro was only invoked conditionally." "$LINENO" 5
5263 fi
5264 if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
5265 as_fn_error "conditional \"am__fastdepCC\" was never defined.
5266 Usually this means the macro was only invoked conditionally." "$LINENO" 5
5267 fi
5268 if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
5269 as_fn_error "conditional \"am__fastdepCC\" was never defined.
5270 Usually this means the macro was only invoked conditionally." "$LINENO" 5
5271 fi
5272
5273 : ${CONFIG_STATUS=./config.status}
5274 ac_write_fail=0
5275 ac_clean_files_save=$ac_clean_files
5276 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
5277 { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
5278 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
5279 as_write_fail=0
5280 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
5281 #! $SHELL
5282 # Generated by $as_me.
5283 # Run this file to recreate the current configuration.
5284 # Compiler output produced by configure, useful for debugging
5285 # configure, is in config.log if it exists.
5286
5287 debug=false
5288 ac_cs_recheck=false
5289 ac_cs_silent=false
5290
5291 SHELL=\${CONFIG_SHELL-$SHELL}
5292 export SHELL
5293 _ASEOF
5294 cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
5295 ## -------------------- ##
5296 ## M4sh Initialization. ##
5297 ## -------------------- ##
5298
5299 # Be more Bourne compatible
5300 DUALCASE=1; export DUALCASE # for MKS sh
5301 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
5302 emulate sh
5303 NULLCMD=:
5304 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
5305 # is contrary to our usage. Disable this feature.
5306 alias -g '${1+"$@"}'='"$@"'
5307 setopt NO_GLOB_SUBST
5308 else
5309 case `(set -o) 2>/dev/null` in #(
5310 *posix*) :
5311 set -o posix ;; #(
5312 *) :
5313 ;;
5314 esac
5315 fi
5316
5317
5318 as_nl='
5319 '
5320 export as_nl
5321 # Printing a long string crashes Solaris 7 /usr/bin/printf.
5322 as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
5323 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
5324 as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
5325 # Prefer a ksh shell builtin over an external printf program on Solaris,
5326 # but without wasting forks for bash or zsh.
5327 if test -z "$BASH_VERSION$ZSH_VERSION" \
5328 && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
5329 as_echo='print -r --'
5330 as_echo_n='print -rn --'
5331 elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
5332 as_echo='printf %s\n'
5333 as_echo_n='printf %s'
5334 else
5335 if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
5336 as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
5337 as_echo_n='/usr/ucb/echo -n'
5338 else
5339 as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
5340 as_echo_n_body='eval
5341 arg=$1;
5342 case $arg in #(
5343 *"$as_nl"*)
5344 expr "X$arg" : "X\\(.*\\)$as_nl";
5345 arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
5346 esac;
5347 expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
5348 '
5349 export as_echo_n_body
5350 as_echo_n='sh -c $as_echo_n_body as_echo'
5351 fi
5352 export as_echo_body
5353 as_echo='sh -c $as_echo_body as_echo'
5354 fi
5355
5356 # The user is always right.
5357 if test "${PATH_SEPARATOR+set}" != set; then
5358 PATH_SEPARATOR=:
5359 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
5360 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
5361 PATH_SEPARATOR=';'
5362 }
5363 fi
5364
5365
5366 # IFS
5367 # We need space, tab and new line, in precisely that order. Quoting is
5368 # there to prevent editors from complaining about space-tab.
5369 # (If _AS_PATH_WALK were called with IFS unset, it would disable word
5370 # splitting by setting IFS to empty value.)
5371 IFS=" "" $as_nl"
5372
5373 # Find who we are. Look in the path if we contain no directory separator.
5374 case $0 in #((
5375 *[\\/]* ) as_myself=$0 ;;
5376 *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
5377 for as_dir in $PATH
5378 do
5379 IFS=$as_save_IFS
5380 test -z "$as_dir" && as_dir=.
5381 test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
5382 done
5383 IFS=$as_save_IFS
5384
5385 ;;
5386 esac
5387 # We did not find ourselves, most probably we were run as `sh COMMAND'
5388 # in which case we are not to be found in the path.
5389 if test "x$as_myself" = x; then
5390 as_myself=$0
5391 fi
5392 if test ! -f "$as_myself"; then
5393 $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
5394 exit 1
5395 fi
5396
5397 # Unset variables that we do not need and which cause bugs (e.g. in
5398 # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
5399 # suppresses any "Segmentation fault" message there. '((' could
5400 # trigger a bug in pdksh 5.2.14.
5401 for as_var in BASH_ENV ENV MAIL MAILPATH
5402 do eval test x\${$as_var+set} = xset \
5403 && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
5404 done
5405 PS1='$ '
5406 PS2='> '
5407 PS4='+ '
5408
5409 # NLS nuisances.
5410 LC_ALL=C
5411 export LC_ALL
5412 LANGUAGE=C
5413 export LANGUAGE
5414
5415 # CDPATH.
5416 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
5417
5418
5419 # as_fn_error ERROR [LINENO LOG_FD]
5420 # ---------------------------------
5421 # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
5422 # provided, also output the error to LOG_FD, referencing LINENO. Then exit the
5423 # script with status $?, using 1 if that was 0.
5424 as_fn_error ()
5425 {
5426 as_status=$?; test $as_status -eq 0 && as_status=1
5427 if test "$3"; then
5428 as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
5429 $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
5430 fi
5431 $as_echo "$as_me: error: $1" >&2
5432 as_fn_exit $as_status
5433 } # as_fn_error
5434
5435
5436 # as_fn_set_status STATUS
5437 # -----------------------
5438 # Set $? to STATUS, without forking.
5439 as_fn_set_status ()
5440 {
5441 return $1
5442 } # as_fn_set_status
5443
5444 # as_fn_exit STATUS
5445 # -----------------
5446 # Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
5447 as_fn_exit ()
5448 {
5449 set +e
5450 as_fn_set_status $1
5451 exit $1
5452 } # as_fn_exit
5453
5454 # as_fn_unset VAR
5455 # ---------------
5456 # Portably unset VAR.
5457 as_fn_unset ()
5458 {
5459 { eval $1=; unset $1;}
5460 }
5461 as_unset=as_fn_unset
5462 # as_fn_append VAR VALUE
5463 # ----------------------
5464 # Append the text in VALUE to the end of the definition contained in VAR. Take
5465 # advantage of any shell optimizations that allow amortized linear growth over
5466 # repeated appends, instead of the typical quadratic growth present in naive
5467 # implementations.
5468 if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
5469 eval 'as_fn_append ()
5470 {
5471 eval $1+=\$2
5472 }'
5473 else
5474 as_fn_append ()
5475 {
5476 eval $1=\$$1\$2
5477 }
5478 fi # as_fn_append
5479
5480 # as_fn_arith ARG...
5481 # ------------------
5482 # Perform arithmetic evaluation on the ARGs, and store the result in the
5483 # global $as_val. Take advantage of shells that can avoid forks. The arguments
5484 # must be portable across $(()) and expr.
5485 if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
5486 eval 'as_fn_arith ()
5487 {
5488 as_val=$(( $* ))
5489 }'
5490 else
5491 as_fn_arith ()
5492 {
5493 as_val=`expr "$@" || test $? -eq 1`
5494 }
5495 fi # as_fn_arith
5496
5497
5498 if expr a : '\(a\)' >/dev/null 2>&1 &&
5499 test "X`expr 00001 : '.*\(...\)'`" = X001; then
5500 as_expr=expr
5501 else
5502 as_expr=false
5503 fi
5504
5505 if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
5506 as_basename=basename
5507 else
5508 as_basename=false
5509 fi
5510
5511 if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
5512 as_dirname=dirname
5513 else
5514 as_dirname=false
5515 fi
5516
5517 as_me=`$as_basename -- "$0" ||
5518 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
5519 X"$0" : 'X\(//\)$' \| \
5520 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
5521 $as_echo X/"$0" |
5522 sed '/^.*\/\([^/][^/]*\)\/*$/{
5523 s//\1/
5524 q
5525 }
5526 /^X\/\(\/\/\)$/{
5527 s//\1/
5528 q
5529 }
5530 /^X\/\(\/\).*/{
5531 s//\1/
5532 q
5533 }
5534 s/.*/./; q'`
5535
5536 # Avoid depending upon Character Ranges.
5537 as_cr_letters='abcdefghijklmnopqrstuvwxyz'
5538 as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
5539 as_cr_Letters=$as_cr_letters$as_cr_LETTERS
5540 as_cr_digits='0123456789'
5541 as_cr_alnum=$as_cr_Letters$as_cr_digits
5542
5543 ECHO_C= ECHO_N= ECHO_T=
5544 case `echo -n x` in #(((((
5545 -n*)
5546 case `echo 'xy\c'` in
5547 *c*) ECHO_T=' ';; # ECHO_T is single tab character.
5548 xy) ECHO_C='\c';;
5549 *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
5550 ECHO_T=' ';;
5551 esac;;
5552 *)
5553 ECHO_N='-n';;
5554 esac
5555
5556 rm -f conf$$ conf$$.exe conf$$.file
5557 if test -d conf$$.dir; then
5558 rm -f conf$$.dir/conf$$.file
5559 else
5560 rm -f conf$$.dir
5561 mkdir conf$$.dir 2>/dev/null
5562 fi
5563 if (echo >conf$$.file) 2>/dev/null; then
5564 if ln -s conf$$.file conf$$ 2>/dev/null; then
5565 as_ln_s='ln -s'
5566 # ... but there are two gotchas:
5567 # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
5568 # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
5569 # In both cases, we have to default to `cp -p'.
5570 ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
5571 as_ln_s='cp -p'
5572 elif ln conf$$.file conf$$ 2>/dev/null; then
5573 as_ln_s=ln
5574 else
5575 as_ln_s='cp -p'
5576 fi
5577 else
5578 as_ln_s='cp -p'
5579 fi
5580 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
5581 rmdir conf$$.dir 2>/dev/null
5582
5583
5584 # as_fn_mkdir_p
5585 # -------------
5586 # Create "$as_dir" as a directory, including parents if necessary.
5587 as_fn_mkdir_p ()
5588 {
5589
5590 case $as_dir in #(
5591 -*) as_dir=./$as_dir;;
5592 esac
5593 test -d "$as_dir" || eval $as_mkdir_p || {
5594 as_dirs=
5595 while :; do
5596 case $as_dir in #(
5597 *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
5598 *) as_qdir=$as_dir;;
5599 esac
5600 as_dirs="'$as_qdir' $as_dirs"
5601 as_dir=`$as_dirname -- "$as_dir" ||
5602 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
5603 X"$as_dir" : 'X\(//\)[^/]' \| \
5604 X"$as_dir" : 'X\(//\)$' \| \
5605 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
5606 $as_echo X"$as_dir" |
5607 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
5608 s//\1/
5609 q
5610 }
5611 /^X\(\/\/\)[^/].*/{
5612 s//\1/
5613 q
5614 }
5615 /^X\(\/\/\)$/{
5616 s//\1/
5617 q
5618 }
5619 /^X\(\/\).*/{
5620 s//\1/
5621 q
5622 }
5623 s/.*/./; q'`
5624 test -d "$as_dir" && break
5625 done
5626 test -z "$as_dirs" || eval "mkdir $as_dirs"
5627 } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
5628
5629
5630 } # as_fn_mkdir_p
5631 if mkdir -p . 2>/dev/null; then
5632 as_mkdir_p='mkdir -p "$as_dir"'
5633 else
5634 test -d ./-p && rmdir ./-p
5635 as_mkdir_p=false
5636 fi
5637
5638 if test -x / >/dev/null 2>&1; then
5639 as_test_x='test -x'
5640 else
5641 if ls -dL / >/dev/null 2>&1; then
5642 as_ls_L_option=L
5643 else
5644 as_ls_L_option=
5645 fi
5646 as_test_x='
5647 eval sh -c '\''
5648 if test -d "$1"; then
5649 test -d "$1/.";
5650 else
5651 case $1 in #(
5652 -*)set "./$1";;
5653 esac;
5654 case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
5655 ???[sx]*):;;*)false;;esac;fi
5656 '\'' sh
5657 '
5658 fi
5659 as_executable_p=$as_test_x
5660
5661 # Sed expression to map a string onto a valid CPP name.
5662 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
5663
5664 # Sed expression to map a string onto a valid variable name.
5665 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
5666
5667
5668 exec 6>&1
5669 ## ----------------------------------- ##
5670 ## Main body of $CONFIG_STATUS script. ##
5671 ## ----------------------------------- ##
5672 _ASEOF
5673 test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
5674
5675 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
5676 # Save the log message, to keep $0 and so on meaningful, and to
5677 # report actual input values of CONFIG_FILES etc. instead of their
5678 # values after options handling.
5679 ac_log="
5680 This file was extended by $as_me, which was
5681 generated by GNU Autoconf 2.65. Invocation command line was
5682
5683 CONFIG_FILES = $CONFIG_FILES
5684 CONFIG_HEADERS = $CONFIG_HEADERS
5685 CONFIG_LINKS = $CONFIG_LINKS
5686 CONFIG_COMMANDS = $CONFIG_COMMANDS
5687 $ $0 $@
5688
5689 on `(hostname || uname -n) 2>/dev/null | sed 1q`
5690 "
5691
5692 _ACEOF
5693
5694 case $ac_config_files in *"
5695 "*) set x $ac_config_files; shift; ac_config_files=$*;;
5696 esac
5697
5698 case $ac_config_headers in *"
5699 "*) set x $ac_config_headers; shift; ac_config_headers=$*;;
5700 esac
5701
5702
5703 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
5704 # Files that config.status was made for.
5705 config_files="$ac_config_files"
5706 config_headers="$ac_config_headers"
5707 config_commands="$ac_config_commands"
5708
5709 _ACEOF
5710
5711 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
5712 ac_cs_usage="\
5713 \`$as_me' instantiates files and other configuration actions
5714 from templates according to the current configuration. Unless the files
5715 and actions are specified as TAGs, all are instantiated by default.
5716
5717 Usage: $0 [OPTION]... [TAG]...
5718
5719 -h, --help print this help, then exit
5720 -V, --version print version number and configuration settings, then exit
5721 --config print configuration, then exit
5722 -q, --quiet, --silent
5723 do not print progress messages
5724 -d, --debug don't remove temporary files
5725 --recheck update $as_me by reconfiguring in the same conditions
5726 --file=FILE[:TEMPLATE]
5727 instantiate the configuration file FILE
5728 --header=FILE[:TEMPLATE]
5729 instantiate the configuration header FILE
5730
5731 Configuration files:
5732 $config_files
5733
5734 Configuration headers:
5735 $config_headers
5736
5737 Configuration commands:
5738 $config_commands
5739
5740 Report bugs to the package provider."
5741
5742 _ACEOF
5743 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
5744 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
5745 ac_cs_version="\\
5746 config.status
5747 configured by $0, generated by GNU Autoconf 2.65,
5748 with options \\"\$ac_cs_config\\"
5749
5750 Copyright (C) 2009 Free Software Foundation, Inc.
5751 This config.status script is free software; the Free Software Foundation
5752 gives unlimited permission to copy, distribute and modify it."
5753
5754 ac_pwd='$ac_pwd'
5755 srcdir='$srcdir'
5756 INSTALL='$INSTALL'
5757 MKDIR_P='$MKDIR_P'
5758 AWK='$AWK'
5759 test -n "\$AWK" || AWK=awk
5760 _ACEOF
5761
5762 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
5763 # The default lists apply if the user does not specify any file.
5764 ac_need_defaults=:
5765 while test $# != 0
5766 do
5767 case $1 in
5768 --*=*)
5769 ac_option=`expr "X$1" : 'X\([^=]*\)='`
5770 ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
5771 ac_shift=:
5772 ;;
5773 *)
5774 ac_option=$1
5775 ac_optarg=$2
5776 ac_shift=shift
5777 ;;
5778 esac
5779
5780 case $ac_option in
5781 # Handling of the options.
5782 -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
5783 ac_cs_recheck=: ;;
5784 --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
5785 $as_echo "$ac_cs_version"; exit ;;
5786 --config | --confi | --conf | --con | --co | --c )
5787 $as_echo "$ac_cs_config"; exit ;;
5788 --debug | --debu | --deb | --de | --d | -d )
5789 debug=: ;;
5790 --file | --fil | --fi | --f )
5791 $ac_shift
5792 case $ac_optarg in
5793 *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
5794 esac
5795 as_fn_append CONFIG_FILES " '$ac_optarg'"
5796 ac_need_defaults=false;;
5797 --header | --heade | --head | --hea )
5798 $ac_shift
5799 case $ac_optarg in
5800 *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
5801 esac
5802 as_fn_append CONFIG_HEADERS " '$ac_optarg'"
5803 ac_need_defaults=false;;
5804 --he | --h)
5805 # Conflict between --help and --header
5806 as_fn_error "ambiguous option: \`$1'
5807 Try \`$0 --help' for more information.";;
5808 --help | --hel | -h )
5809 $as_echo "$ac_cs_usage"; exit ;;
5810 -q | -quiet | --quiet | --quie | --qui | --qu | --q \
5811 | -silent | --silent | --silen | --sile | --sil | --si | --s)
5812 ac_cs_silent=: ;;
5813
5814 # This is an error.
5815 -*) as_fn_error "unrecognized option: \`$1'
5816 Try \`$0 --help' for more information." ;;
5817
5818 *) as_fn_append ac_config_targets " $1"
5819 ac_need_defaults=false ;;
5820
5821 esac
5822 shift
5823 done
5824
5825 ac_configure_extra_args=
5826
5827 if $ac_cs_silent; then
5828 exec 6>/dev/null
5829 ac_configure_extra_args="$ac_configure_extra_args --silent"
5830 fi
5831
5832 _ACEOF
5833 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
5834 if \$ac_cs_recheck; then
5835 set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
5836 shift
5837 \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
5838 CONFIG_SHELL='$SHELL'
5839 export CONFIG_SHELL
5840 exec "\$@"
5841 fi
5842
5843 _ACEOF
5844 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
5845 exec 5>>config.log
5846 {
5847 echo
5848 sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
5849 ## Running $as_me. ##
5850 _ASBOX
5851 $as_echo "$ac_log"
5852 } >&5
5853
5854 _ACEOF
5855 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
5856 #
5857 # INIT-COMMANDS
5858 #
5859 AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
5860
5861 _ACEOF
5862
5863 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
5864
5865 # Handling of arguments.
5866 for ac_config_target in $ac_config_targets
5867 do
5868 case $ac_config_target in
5869 "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
5870 "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
5871 "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
5872
5873 *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
5874 esac
5875 done
5876
5877
5878 # If the user did not use the arguments to specify the items to instantiate,
5879 # then the envvar interface is used. Set only those that are not.
5880 # We use the long form for the default assignment because of an extremely
5881 # bizarre bug on SunOS 4.1.3.
5882 if $ac_need_defaults; then
5883 test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
5884 test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
5885 test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
5886 fi
5887
5888 # Have a temporary directory for convenience. Make it in the build tree
5889 # simply because there is no reason against having it here, and in addition,
5890 # creating and moving files from /tmp can sometimes cause problems.
5891 # Hook for its removal unless debugging.
5892 # Note that there is a small window in which the directory will not be cleaned:
5893 # after its creation but before its name has been assigned to `$tmp'.
5894 $debug ||
5895 {
5896 tmp=
5897 trap 'exit_status=$?
5898 { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
5899 ' 0
5900 trap 'as_fn_exit 1' 1 2 13 15
5901 }
5902 # Create a (secure) tmp directory for tmp files.
5903
5904 {
5905 tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
5906 test -n "$tmp" && test -d "$tmp"
5907 } ||
5908 {
5909 tmp=./conf$$-$RANDOM
5910 (umask 077 && mkdir "$tmp")
5911 } || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
5912
5913 # Set up the scripts for CONFIG_FILES section.
5914 # No need to generate them if there are no CONFIG_FILES.
5915 # This happens for instance with `./config.status config.h'.
5916 if test -n "$CONFIG_FILES"; then
5917
5918
5919 ac_cr=`echo X | tr X '\015'`
5920 # On cygwin, bash can eat \r inside `` if the user requested igncr.
5921 # But we know of no other shell where ac_cr would be empty at this
5922 # point, so we can use a bashism as a fallback.
5923 if test "x$ac_cr" = x; then
5924 eval ac_cr=\$\'\\r\'
5925 fi
5926 ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
5927 if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
5928 ac_cs_awk_cr='\r'
5929 else
5930 ac_cs_awk_cr=$ac_cr
5931 fi
5932
5933 echo 'BEGIN {' >"$tmp/subs1.awk" &&
5934 _ACEOF
5935
5936
5937 {
5938 echo "cat >conf$$subs.awk <<_ACEOF" &&
5939 echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
5940 echo "_ACEOF"
5941 } >conf$$subs.sh ||
5942 as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
5943 ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
5944 ac_delim='%!_!# '
5945 for ac_last_try in false false false false false :; do
5946 . ./conf$$subs.sh ||
5947 as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
5948
5949 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
5950 if test $ac_delim_n = $ac_delim_num; then
5951 break
5952 elif $ac_last_try; then
5953 as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
5954 else
5955 ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
5956 fi
5957 done
5958 rm -f conf$$subs.sh
5959
5960 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
5961 cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
5962 _ACEOF
5963 sed -n '
5964 h
5965 s/^/S["/; s/!.*/"]=/
5966 p
5967 g
5968 s/^[^!]*!//
5969 :repl
5970 t repl
5971 s/'"$ac_delim"'$//
5972 t delim
5973 :nl
5974 h
5975 s/\(.\{148\}\)..*/\1/
5976 t more1
5977 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
5978 p
5979 n
5980 b repl
5981 :more1
5982 s/["\\]/\\&/g; s/^/"/; s/$/"\\/
5983 p
5984 g
5985 s/.\{148\}//
5986 t nl
5987 :delim
5988 h
5989 s/\(.\{148\}\)..*/\1/
5990 t more2
5991 s/["\\]/\\&/g; s/^/"/; s/$/"/
5992 p
5993 b
5994 :more2
5995 s/["\\]/\\&/g; s/^/"/; s/$/"\\/
5996 p
5997 g
5998 s/.\{148\}//
5999 t delim
6000 ' <conf$$subs.awk | sed '
6001 /^[^""]/{
6002 N
6003 s/\n//
6004 }
6005 ' >>$CONFIG_STATUS || ac_write_fail=1
6006 rm -f conf$$subs.awk
6007 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
6008 _ACAWK
6009 cat >>"\$tmp/subs1.awk" <<_ACAWK &&
6010 for (key in S) S_is_set[key] = 1
6011 FS = ""
6012
6013 }
6014 {
6015 line = $ 0
6016 nfields = split(line, field, "@")
6017 substed = 0
6018 len = length(field[1])
6019 for (i = 2; i < nfields; i++) {
6020 key = field[i]
6021 keylen = length(key)
6022 if (S_is_set[key]) {
6023 value = S[key]
6024 line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
6025 len += length(value) + length(field[++i])
6026 substed = 1
6027 } else
6028 len += 1 + keylen
6029 }
6030
6031 print line
6032 }
6033
6034 _ACAWK
6035 _ACEOF
6036 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
6037 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
6038 sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
6039 else
6040 cat
6041 fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
6042 || as_fn_error "could not setup config files machinery" "$LINENO" 5
6043 _ACEOF
6044
6045 # VPATH may cause trouble with some makes, so we remove $(srcdir),
6046 # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
6047 # trailing colons and then remove the whole line if VPATH becomes empty
6048 # (actually we leave an empty line to preserve line numbers).
6049 if test "x$srcdir" = x.; then
6050 ac_vpsub='/^[ ]*VPATH[ ]*=/{
6051 s/:*\$(srcdir):*/:/
6052 s/:*\${srcdir}:*/:/
6053 s/:*@srcdir@:*/:/
6054 s/^\([^=]*=[ ]*\):*/\1/
6055 s/:*$//
6056 s/^[^=]*=[ ]*$//
6057 }'
6058 fi
6059
6060 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
6061 fi # test -n "$CONFIG_FILES"
6062
6063 # Set up the scripts for CONFIG_HEADERS section.
6064 # No need to generate them if there are no CONFIG_HEADERS.
6065 # This happens for instance with `./config.status Makefile'.
6066 if test -n "$CONFIG_HEADERS"; then
6067 cat >"$tmp/defines.awk" <<\_ACAWK ||
6068 BEGIN {
6069 _ACEOF
6070
6071 # Transform confdefs.h into an awk script `defines.awk', embedded as
6072 # here-document in config.status, that substitutes the proper values into
6073 # config.h.in to produce config.h.
6074
6075 # Create a delimiter string that does not exist in confdefs.h, to ease
6076 # handling of long lines.
6077 ac_delim='%!_!# '
6078 for ac_last_try in false false :; do
6079 ac_t=`sed -n "/$ac_delim/p" confdefs.h`
6080 if test -z "$ac_t"; then
6081 break
6082 elif $ac_last_try; then
6083 as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
6084 else
6085 ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
6086 fi
6087 done
6088
6089 # For the awk script, D is an array of macro values keyed by name,
6090 # likewise P contains macro parameters if any. Preserve backslash
6091 # newline sequences.
6092
6093 ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
6094 sed -n '
6095 s/.\{148\}/&'"$ac_delim"'/g
6096 t rset
6097 :rset
6098 s/^[ ]*#[ ]*define[ ][ ]*/ /
6099 t def
6100 d
6101 :def
6102 s/\\$//
6103 t bsnl
6104 s/["\\]/\\&/g
6105 s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
6106 D["\1"]=" \3"/p
6107 s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
6108 d
6109 :bsnl
6110 s/["\\]/\\&/g
6111 s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
6112 D["\1"]=" \3\\\\\\n"\\/p
6113 t cont
6114 s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
6115 t cont
6116 d
6117 :cont
6118 n
6119 s/.\{148\}/&'"$ac_delim"'/g
6120 t clear
6121 :clear
6122 s/\\$//
6123 t bsnlc
6124 s/["\\]/\\&/g; s/^/"/; s/$/"/p
6125 d
6126 :bsnlc
6127 s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
6128 b cont
6129 ' <confdefs.h | sed '
6130 s/'"$ac_delim"'/"\\\
6131 "/g' >>$CONFIG_STATUS || ac_write_fail=1
6132
6133 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
6134 for (key in D) D_is_set[key] = 1
6135 FS = ""
6136 }
6137 /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
6138 line = \$ 0
6139 split(line, arg, " ")
6140 if (arg[1] == "#") {
6141 defundef = arg[2]
6142 mac1 = arg[3]
6143 } else {
6144 defundef = substr(arg[1], 2)
6145 mac1 = arg[2]
6146 }
6147 split(mac1, mac2, "(") #)
6148 macro = mac2[1]
6149 prefix = substr(line, 1, index(line, defundef) - 1)
6150 if (D_is_set[macro]) {
6151 # Preserve the white space surrounding the "#".
6152 print prefix "define", macro P[macro] D[macro]
6153 next
6154 } else {
6155 # Replace #undef with comments. This is necessary, for example,
6156 # in the case of _POSIX_SOURCE, which is predefined and required
6157 # on some systems where configure will not decide to define it.
6158 if (defundef == "undef") {
6159 print "/*", prefix defundef, macro, "*/"
6160 next
6161 }
6162 }
6163 }
6164 { print }
6165 _ACAWK
6166 _ACEOF
6167 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
6168 as_fn_error "could not setup config headers machinery" "$LINENO" 5
6169 fi # test -n "$CONFIG_HEADERS"
6170
6171
6172 eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS"
6173 shift
6174 for ac_tag
6175 do
6176 case $ac_tag in
6177 :[FHLC]) ac_mode=$ac_tag; continue;;
6178 esac
6179 case $ac_mode$ac_tag in
6180 :[FHL]*:*);;
6181 :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
6182 :[FH]-) ac_tag=-:-;;
6183 :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
6184 esac
6185 ac_save_IFS=$IFS
6186 IFS=:
6187 set x $ac_tag
6188 IFS=$ac_save_IFS
6189 shift
6190 ac_file=$1
6191 shift
6192
6193 case $ac_mode in
6194 :L) ac_source=$1;;
6195 :[FH])
6196 ac_file_inputs=
6197 for ac_f
6198 do
6199 case $ac_f in
6200 -) ac_f="$tmp/stdin";;
6201 *) # Look for the file first in the build tree, then in the source tree
6202 # (if the path is not absolute). The absolute path cannot be DOS-style,
6203 # because $ac_f cannot contain `:'.
6204 test -f "$ac_f" ||
6205 case $ac_f in
6206 [\\/$]*) false;;
6207 *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
6208 esac ||
6209 as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
6210 esac
6211 case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
6212 as_fn_append ac_file_inputs " '$ac_f'"
6213 done
6214
6215 # Let's still pretend it is `configure' which instantiates (i.e., don't
6216 # use $as_me), people would be surprised to read:
6217 # /* config.h. Generated by config.status. */
6218 configure_input='Generated from '`
6219 $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
6220 `' by configure.'
6221 if test x"$ac_file" != x-; then
6222 configure_input="$ac_file. $configure_input"
6223 { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
6224 $as_echo "$as_me: creating $ac_file" >&6;}
6225 fi
6226 # Neutralize special characters interpreted by sed in replacement strings.
6227 case $configure_input in #(
6228 *\&* | *\|* | *\\* )
6229 ac_sed_conf_input=`$as_echo "$configure_input" |
6230 sed 's/[\\\\&|]/\\\\&/g'`;; #(
6231 *) ac_sed_conf_input=$configure_input;;
6232 esac
6233
6234 case $ac_tag in
6235 *:-:* | *:-) cat >"$tmp/stdin" \
6236 || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
6237 esac
6238 ;;
6239 esac
6240
6241 ac_dir=`$as_dirname -- "$ac_file" ||
6242 $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
6243 X"$ac_file" : 'X\(//\)[^/]' \| \
6244 X"$ac_file" : 'X\(//\)$' \| \
6245 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
6246 $as_echo X"$ac_file" |
6247 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
6248 s//\1/
6249 q
6250 }
6251 /^X\(\/\/\)[^/].*/{
6252 s//\1/
6253 q
6254 }
6255 /^X\(\/\/\)$/{
6256 s//\1/
6257 q
6258 }
6259 /^X\(\/\).*/{
6260 s//\1/
6261 q
6262 }
6263 s/.*/./; q'`
6264 as_dir="$ac_dir"; as_fn_mkdir_p
6265 ac_builddir=.
6266
6267 case "$ac_dir" in
6268 .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
6269 *)
6270 ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
6271 # A ".." for each directory in $ac_dir_suffix.
6272 ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
6273 case $ac_top_builddir_sub in
6274 "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
6275 *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
6276 esac ;;
6277 esac
6278 ac_abs_top_builddir=$ac_pwd
6279 ac_abs_builddir=$ac_pwd$ac_dir_suffix
6280 # for backward compatibility:
6281 ac_top_builddir=$ac_top_build_prefix
6282
6283 case $srcdir in
6284 .) # We are building in place.
6285 ac_srcdir=.
6286 ac_top_srcdir=$ac_top_builddir_sub
6287 ac_abs_top_srcdir=$ac_pwd ;;
6288 [\\/]* | ?:[\\/]* ) # Absolute name.
6289 ac_srcdir=$srcdir$ac_dir_suffix;
6290 ac_top_srcdir=$srcdir
6291 ac_abs_top_srcdir=$srcdir ;;
6292 *) # Relative name.
6293 ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
6294 ac_top_srcdir=$ac_top_build_prefix$srcdir
6295 ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
6296 esac
6297 ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
6298
6299
6300 case $ac_mode in
6301 :F)
6302 #
6303 # CONFIG_FILE
6304 #
6305
6306 case $INSTALL in
6307 [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
6308 *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
6309 esac
6310 ac_MKDIR_P=$MKDIR_P
6311 case $MKDIR_P in
6312 [\\/$]* | ?:[\\/]* ) ;;
6313 */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
6314 esac
6315 _ACEOF
6316
6317 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
6318 # If the template does not know about datarootdir, expand it.
6319 # FIXME: This hack should be removed a few years after 2.60.
6320 ac_datarootdir_hack=; ac_datarootdir_seen=
6321 ac_sed_dataroot='
6322 /datarootdir/ {
6323 p
6324 q
6325 }
6326 /@datadir@/p
6327 /@docdir@/p
6328 /@infodir@/p
6329 /@localedir@/p
6330 /@mandir@/p'
6331 case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
6332 *datarootdir*) ac_datarootdir_seen=yes;;
6333 *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
6334 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
6335 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
6336 _ACEOF
6337 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
6338 ac_datarootdir_hack='
6339 s&@datadir@&$datadir&g
6340 s&@docdir@&$docdir&g
6341 s&@infodir@&$infodir&g
6342 s&@localedir@&$localedir&g
6343 s&@mandir@&$mandir&g
6344 s&\\\${datarootdir}&$datarootdir&g' ;;
6345 esac
6346 _ACEOF
6347
6348 # Neutralize VPATH when `$srcdir' = `.'.
6349 # Shell code in configure.ac might set extrasub.
6350 # FIXME: do we really want to maintain this feature?
6351 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
6352 ac_sed_extra="$ac_vpsub
6353 $extrasub
6354 _ACEOF
6355 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
6356 :t
6357 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
6358 s|@configure_input@|$ac_sed_conf_input|;t t
6359 s&@top_builddir@&$ac_top_builddir_sub&;t t
6360 s&@top_build_prefix@&$ac_top_build_prefix&;t t
6361 s&@srcdir@&$ac_srcdir&;t t
6362 s&@abs_srcdir@&$ac_abs_srcdir&;t t
6363 s&@top_srcdir@&$ac_top_srcdir&;t t
6364 s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
6365 s&@builddir@&$ac_builddir&;t t
6366 s&@abs_builddir@&$ac_abs_builddir&;t t
6367 s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
6368 s&@INSTALL@&$ac_INSTALL&;t t
6369 s&@MKDIR_P@&$ac_MKDIR_P&;t t
6370 $ac_datarootdir_hack
6371 "
6372 eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
6373 || as_fn_error "could not create $ac_file" "$LINENO" 5
6374
6375 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
6376 { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
6377 { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
6378 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
6379 which seems to be undefined. Please make sure it is defined." >&5
6380 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
6381 which seems to be undefined. Please make sure it is defined." >&2;}
6382
6383 rm -f "$tmp/stdin"
6384 case $ac_file in
6385 -) cat "$tmp/out" && rm -f "$tmp/out";;
6386 *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
6387 esac \
6388 || as_fn_error "could not create $ac_file" "$LINENO" 5
6389 ;;
6390 :H)
6391 #
6392 # CONFIG_HEADER
6393 #
6394 if test x"$ac_file" != x-; then
6395 {
6396 $as_echo "/* $configure_input */" \
6397 && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
6398 } >"$tmp/config.h" \
6399 || as_fn_error "could not create $ac_file" "$LINENO" 5
6400 if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
6401 { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
6402 $as_echo "$as_me: $ac_file is unchanged" >&6;}
6403 else
6404 rm -f "$ac_file"
6405 mv "$tmp/config.h" "$ac_file" \
6406 || as_fn_error "could not create $ac_file" "$LINENO" 5
6407 fi
6408 else
6409 $as_echo "/* $configure_input */" \
6410 && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
6411 || as_fn_error "could not create -" "$LINENO" 5
6412 fi
6413 # Compute "$ac_file"'s index in $config_headers.
6414 _am_arg="$ac_file"
6415 _am_stamp_count=1
6416 for _am_header in $config_headers :; do
6417 case $_am_header in
6418 $_am_arg | $_am_arg:* )
6419 break ;;
6420 * )
6421 _am_stamp_count=`expr $_am_stamp_count + 1` ;;
6422 esac
6423 done
6424 echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
6425 $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
6426 X"$_am_arg" : 'X\(//\)[^/]' \| \
6427 X"$_am_arg" : 'X\(//\)$' \| \
6428 X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
6429 $as_echo X"$_am_arg" |
6430 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
6431 s//\1/
6432 q
6433 }
6434 /^X\(\/\/\)[^/].*/{
6435 s//\1/
6436 q
6437 }
6438 /^X\(\/\/\)$/{
6439 s//\1/
6440 q
6441 }
6442 /^X\(\/\).*/{
6443 s//\1/
6444 q
6445 }
6446 s/.*/./; q'`/stamp-h$_am_stamp_count
6447 ;;
6448
6449 :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
6450 $as_echo "$as_me: executing $ac_file commands" >&6;}
6451 ;;
6452 esac
6453
6454
6455 case $ac_file$ac_mode in
6456 "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
6457 # Autoconf 2.62 quotes --file arguments for eval, but not when files
6458 # are listed without --file. Let's play safe and only enable the eval
6459 # if we detect the quoting.
6460 case $CONFIG_FILES in
6461 *\'*) eval set x "$CONFIG_FILES" ;;
6462 *) set x $CONFIG_FILES ;;
6463 esac
6464 shift
6465 for mf
6466 do
6467 # Strip MF so we end up with the name of the file.
6468 mf=`echo "$mf" | sed -e 's/:.*$//'`
6469 # Check whether this is an Automake generated Makefile or not.
6470 # We used to match only the files named `Makefile.in', but
6471 # some people rename them; so instead we look at the file content.
6472 # Grep'ing the first line is not enough: some people post-process
6473 # each Makefile.in and add a new line on top of each file to say so.
6474 # Grep'ing the whole file is not good either: AIX grep has a line
6475 # limit of 2048, but all sed's we know have understand at least 4000.
6476 if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
6477 dirpart=`$as_dirname -- "$mf" ||
6478 $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
6479 X"$mf" : 'X\(//\)[^/]' \| \
6480 X"$mf" : 'X\(//\)$' \| \
6481 X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
6482 $as_echo X"$mf" |
6483 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
6484 s//\1/
6485 q
6486 }
6487 /^X\(\/\/\)[^/].*/{
6488 s//\1/
6489 q
6490 }
6491 /^X\(\/\/\)$/{
6492 s//\1/
6493 q
6494 }
6495 /^X\(\/\).*/{
6496 s//\1/
6497 q
6498 }
6499 s/.*/./; q'`
6500 else
6501 continue
6502 fi
6503 # Extract the definition of DEPDIR, am__include, and am__quote
6504 # from the Makefile without running `make'.
6505 DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
6506 test -z "$DEPDIR" && continue
6507 am__include=`sed -n 's/^am__include = //p' < "$mf"`
6508 test -z "am__include" && continue
6509 am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
6510 # When using ansi2knr, U may be empty or an underscore; expand it
6511 U=`sed -n 's/^U = //p' < "$mf"`
6512 # Find all dependency output files, they are included files with
6513 # $(DEPDIR) in their names. We invoke sed twice because it is the
6514 # simplest approach to changing $(DEPDIR) to its actual value in the
6515 # expansion.
6516 for file in `sed -n "
6517 s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
6518 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
6519 # Make sure the directory exists.
6520 test -f "$dirpart/$file" && continue
6521 fdir=`$as_dirname -- "$file" ||
6522 $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
6523 X"$file" : 'X\(//\)[^/]' \| \
6524 X"$file" : 'X\(//\)$' \| \
6525 X"$file" : 'X\(/\)' \| . 2>/dev/null ||
6526 $as_echo X"$file" |
6527 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
6528 s//\1/
6529 q
6530 }
6531 /^X\(\/\/\)[^/].*/{
6532 s//\1/
6533 q
6534 }
6535 /^X\(\/\/\)$/{
6536 s//\1/
6537 q
6538 }
6539 /^X\(\/\).*/{
6540 s//\1/
6541 q
6542 }
6543 s/.*/./; q'`
6544 as_dir=$dirpart/$fdir; as_fn_mkdir_p
6545 # echo "creating $dirpart/$file"
6546 echo '# dummy' > "$dirpart/$file"
6547 done
6548 done
6549 }
6550 ;;
6551
6552 esac
6553 done # for ac_tag
6554
6555
6556 as_fn_exit 0
6557 _ACEOF
6558 ac_clean_files=$ac_clean_files_save
6559
6560 test $ac_write_fail = 0 ||
6561 as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
6562
6563
6564 # configure is writing to config.log, and then calls config.status.
6565 # config.status does its own redirection, appending to config.log.
6566 # Unfortunately, on DOS this fails, as config.log is still kept open
6567 # by configure, so config.status won't be able to write to it; its
6568 # output is simply discarded. So we exec the FD to /dev/null,
6569 # effectively closing config.log, so it can be properly (re)opened and
6570 # appended to by config.status. When coming back to configure, we
6571 # need to make the FD available again.
6572 if test "$no_create" != yes; then
6573 ac_cs_success=:
6574 ac_config_status_args=
6575 test "$silent" = yes &&
6576 ac_config_status_args="$ac_config_status_args --quiet"
6577 exec 5>/dev/null
6578 $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
6579 exec 5>>config.log
6580 # Use ||, not &&, to avoid exiting from the if with $? = 1, which
6581 # would make configure fail if this is the last instruction.
6582 $ac_cs_success || as_fn_exit $?
6583 fi
6584 if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
6585 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
6586 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
6587 fi
6588
6589
+0
-198
configure.in less more
0 dnl this files has to be processed by autoconf
1 AC_PREREQ(2.61)
2
3 AC_INIT
4 AC_CONFIG_SRCDIR([README])
5 AC_CONFIG_SRCDIR(job.c)
6 AC_CONFIG_HEADERS(config.h)
7 AC_CONFIG_MACRO_DIR([m4])
8
9 AM_INIT_AUTOMAKE(beanstalkd,$($srcdir/version.sh))
10 AM_MAINTAINER_MODE
11
12 AS_COMPILER_FLAGS(CFLAGS, "-Wall -Werror")
13
14 AC_PROG_CC
15 AC_PROG_INSTALL
16
17 DEFAULT_INSTALL_PREFIX="/usr/local"
18 STANDARD_PREFIXES="/usr /usr/local /opt /local"
19
20
21 dnl {{{ --with-libdir
22 AC_ARG_WITH(libdir,
23 [AS_HELP_STRING([--with-libdir],[look for libraries in .../NAME rather than .../lib])
24 ],
25 [LIBDIR=$with_libdir],
26 [LIBDIR=lib]
27 )
28 dnl }}}
29
30 dnl {{{ --disable-rpath
31 AC_ARG_ENABLE(rpath,
32 [AS_HELP_STRING([--disable-rpath],[disable passing additional runtime library search paths])
33 ],
34 [BEAN_RPATH=no],
35 [BEAN_RPATH=yes]
36 )
37 dnl }}}
38
39 dnl {{{ check for rpath support
40 AC_MSG_CHECKING([if compiler supports -R])
41 AC_CACHE_VAL(bt_cv_cc_dashr,[
42 SAVE_LIBS=$LIBS
43 LIBS="-R /usr/$LIBDIR $LIBS"
44 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[bt_cv_cc_dashr=yes],[bt_cv_cc_dashr=no])
45 LIBS=$SAVE_LIBS])
46 AC_MSG_RESULT([$bt_cv_cc_dashr])
47 if test $bt_cv_cc_dashr = "yes"; then
48 ld_runpath_switch=-R
49 else
50 AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
51 AC_CACHE_VAL(bt_cv_cc_rpath,[
52 SAVE_LIBS=$LIBS
53 LIBS="-Wl,-rpath,/usr/$LIBDIR $LIBS"
54 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[bt_cv_cc_rpath=yes],[bt_cv_cc_rpath=no])
55 LIBS=$SAVE_LIBS])
56 AC_MSG_RESULT([$bt_cv_cc_rpath])
57 if test $bt_cv_cc_rpath = "yes"; then
58 ld_runpath_switch=-Wl,-rpath,
59 else
60 ld_runpath_switch=-L
61 fi
62 fi
63 if test "$BEAN_RPATH" = "no"; then
64 ld_runpath_switch=
65 fi
66 dnl }}}
67
68 dnl {{{ --with-event
69 AC_ARG_WITH(event,
70 [AS_HELP_STRING([--with-event],[specify libevent install prefix])
71 ],
72 [ ],
73 [with_event=yes]
74 )
75
76 if test "x$with_event" = "xno"; then
77 AC_MSG_ERROR([can't continue without libevent])
78 else
79 AC_MSG_CHECKING([libevent install prefix])
80
81 if test "x$with_event" = "xyes"; then
82 for i in `echo "$STANDARD_PREFIXES"`; do
83 if test -f "$i/include/event.h"; then
84 LIBEVENT_DIR="$i"
85 break;
86 fi
87 done
88 else
89 if test -f "$with_event/include/event.h"; then
90 LIBEVENT_DIR="$with_event"
91 break;
92 else
93 AC_MSG_ERROR([Can't find libevent headers under $with_event directory])
94 fi
95 fi
96
97 if test "x$LIBEVENT_DIR" = "x"; then
98 AC_MSG_ERROR([Unable to locate libevent headers, please use --with-event=<DIR>])
99 fi
100
101 AC_MSG_RESULT([$LIBEVENT_DIR])
102 LDFLAGS="$LDFLAGS -L$LIBEVENT_DIR/$LIBDIR"
103 CFLAGS="$CFLAGS -I$LIBEVENT_DIR/include"
104 LIBS="$LIBS -levent"
105
106 AC_CHECK_FUNCS([posix_fallocate])
107 dnl {{{ make sure that fdatasync exits
108 AC_CACHE_CHECK([for fdatasync],[ac_cv_func_fdatasync],[
109 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
110 #include <unistd.h>
111 ]],[[
112 fdatasync(4);
113 ]])],
114 [ac_cv_func_fdatasync=yes],
115 [ac_cv_func_fdatasync=no])
116 ])
117 AS_IF([test "x${ac_cv_func_fdatasync}" = "xyes"],
118 [AC_DEFINE([HAVE_FDATASYNC],[1],[If the system defines fdatasync])])
119 dnl }}}
120
121 AC_CHECK_LIB([socket], [bind], [
122 LIBS="$LIBS -lsocket"
123 ])
124
125 AC_CHECK_LIB([nsl], [inet_aton], [
126 LIBS="$LIBS -lnsl"
127 ])
128
129 if test "$BEAN_RPATH" != "no"; then
130 LDFLAGS="$LDFLAGS $ld_runpath_switch$LIBEVENT_DIR/$LIBDIR"
131 fi
132
133 AC_CHECK_LIB([event], [event_get_version], [], [
134 AC_MSG_ERROR([event_get_version() is missing, check config.log for more details])
135 ])
136
137 AC_CHECK_LIB([event], [event_reinit], [], [
138 AC_MSG_ERROR([beanstalkd requires libevent version 1.4.1 or later.])
139 ])
140
141 if test -f "$LIBEVENT_DIR/$LIBDIR/libevent.so"; then
142 LIBEVENT="$LIBEVENT_DIR/$LIBDIR/libevent.so";
143 else
144 if test -f "$LIBEVENT_DIR/lib/libevent.so"; then
145 LIBEVENT="$LIBEVENT_DIR/lib/libevent.so";
146 else
147 if test -f "$LIBEVENT_DIR/lib64/libevent.so"; then
148 LIBEVENT="$LIBEVENT_DIR/lib64/libevent.so";
149 fi
150 fi
151 fi
152 fi
153
154 dnl }}}
155
156 dnl {{{ --enable-debug
157 AC_ARG_ENABLE(debug,
158 [AS_HELP_STRING([--enable-debug],[enable debugging symbols and compile flags])
159 ],
160 [
161 if test x"$enableval" = xyes ; then
162 debug="yes"
163 else
164 debug="no"
165 fi
166 ]
167 )
168
169 if test x"$debug" = xyes ; then
170 AC_DEFINE([BEAN_DEBUG], [], [debug build])
171
172 if test x"$GCC" = xyes; then
173 dnl Remove any optimization flags from CFLAGS
174 changequote({,})
175 CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9s]*//g'`
176 CFLAGS=`echo "$CFLAGS" | sed -e 's/-g[0-2]\? //g'`
177 changequote([,])
178 CFLAGS="$CFLAGS -g3 -Wall -O0"
179 fi
180
181 dnl Do not strip symbols from developer object files.
182 INSTALL_STRIP_FLAG=""
183 else
184 dnl Make sure to strip symbols from non-developer object files.
185 INSTALL_STRIP_FLAG="-s"
186 fi
187 dnl }}}
188
189 # Checks for typedefs, structures, and compiler characteristics.
190 AC_TYPE_UINT16_T
191
192 AC_SUBST(INSTALL_STRIP_FLAG)
193
194 AC_CONFIG_FILES([Makefile])
195 AC_OUTPUT
196
197 dnl vim700: ts=2 sw=2 et
0 /* conn.c - network connection state */
1
2 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
0 #include <stdint.h>
1 #include <stdio.h>
182 #include <stdlib.h>
19 #include <stdio.h>
3 #include <string.h>
204 #include <errno.h>
215 #include <limits.h>
22
23 #include "conn.h"
24 #include "net.h"
25 #include "util.h"
26 #include "prot.h"
27
28 #define SAFETY_MARGIN (1 * SECOND)
29
30 /* Doubly-linked list of free connections. */
31 static struct conn pool = { &pool, &pool, 0 };
6 #include <unistd.h>
7 #include "dat.h"
8
9 #define SAFETY_MARGIN (1000000000) /* 1 second */
3210
3311 static int cur_conn_ct = 0, cur_worker_ct = 0, cur_producer_ct = 0;
34 static unsigned int tot_conn_ct = 0;
35
36 static conn
37 conn_alloc()
38 {
39 return conn_remove(pool.next) ? : malloc(sizeof(struct conn));
40 }
41
42 static void
43 conn_free(conn c)
44 {
45 c->fd = 0;
46 conn_insert(&pool, c);
47 }
12 static uint tot_conn_ct = 0;
13 int verbose = 0;
4814
4915 static void
5016 on_watch(ms a, tube t, size_t i)
6632 job j;
6733 conn c;
6834
69 c = conn_alloc();
35 c = new(struct conn);
7036 if (!c) return twarn("OOM"), (conn) 0;
7137
7238 ms_init(&c->watch, (ms_event_fn) on_watch, (ms_event_fn) on_ignore);
7339 if (!ms_append(&c->watch, watch)) {
74 conn_free(c);
40 free(c);
7541 return twarn("OOM"), (conn) 0;
7642 }
7743
78 c->use = NULL; /* initialize */
7944 TUBE_ASSIGN(c->use, use);
8045 use->using_ct++;
8146
82 c->fd = fd;
47 c->sock.fd = fd;
8348 c->state = start_state;
84 c->type = 0;
85 c->cmd_read = 0;
8649 c->pending_timeout = -1;
87 c->soonest_job = NULL;
88 c->in_job = c->out_job = NULL;
89 c->in_job_read = c->out_job_sent = 0;
50 c->tickpos = -1;
9051 c->prev = c->next = c; /* must be out of a linked list right now */
9152 j = &c->reserved_jobs;
9253 j->prev = j->next = j;
12081 return cur_conn_ct;
12182 }
12283
123 unsigned int
84 uint
12485 count_tot_conns()
12586 {
12687 return tot_conn_ct;
144105 return job_list_any_p(&c->reserved_jobs);
145106 }
146107
147 int
148 conn_set_evq(conn c, const int events, evh handler)
149 {
150 int r, margin = 0, should_timeout = 0;
151 struct timeval tv = {INT_MAX, 0};
152 usec t = UINT64_MAX;
153
154 event_set(&c->evq, c->fd, events, handler, c);
155
156 if (conn_waiting(c)) margin = SAFETY_MARGIN;
108
109 static int64
110 conntickat(conn c)
111 {
112 int margin = 0, should_timeout = 0;
113 int64 t = INT64_MAX;
114
115 if (conn_waiting(c)) {
116 margin = SAFETY_MARGIN;
117 }
118
157119 if (has_reserved_job(c)) {
158 t = soonest_job(c)->deadline_at - now_usec() - margin;
120 t = soonest_job(c)->r.deadline_at - nanoseconds() - margin;
159121 should_timeout = 1;
160122 }
161123 if (c->pending_timeout >= 0) {
162 t = min(t, c->pending_timeout * SECOND);
124 t = min(t, ((int64)c->pending_timeout) * 1000000000);
163125 should_timeout = 1;
164126 }
165 if (should_timeout) timeval_from_usec(&tv, t);
166
167 r = event_add(&c->evq, should_timeout ? &tv : NULL);
168 if (r == -1) return twarn("event_add() err %d", errno), -1;
169
127
128 if (should_timeout) {
129 return nanoseconds() + t;
130 }
170131 return 0;
171132 }
172133
173 int
174 conn_update_evq(conn c, const int events)
175 {
176 int r;
177
178 if (!c) return twarnx("c is NULL"), -1;
179
180 /* If it's been added, try to delete it first */
181 if (c->evq.ev_base) {
182 r = event_del(&c->evq);
183 if (r == -1) return twarn("event_del() err %d", errno), -1;
184 }
185
186 return conn_set_evq(c, events, c->evq.ev_callback);
187 }
134
135 void
136 connwant(conn c, int rw, conn list)
137 {
138 c->rw = rw;
139 conn_insert(list, c);
140 connsched(c);
141 }
142
143
144 void
145 connsched(conn c)
146 {
147 c->tickat = conntickat(c);
148 srvschedconn(c->srv, c);
149 }
150
188151
189152 static int
190153 conn_list_any_p(conn head)
225188
226189 if (soonest == NULL) {
227190 for (j = c->reserved_jobs.next; j != &c->reserved_jobs; j = j->next) {
228 if (j->deadline_at <= (soonest ? : j)->deadline_at) soonest = j;
191 if (j->r.deadline_at <= (soonest ? : j)->r.deadline_at) soonest = j;
229192 }
230193 }
231194 c->soonest_job = soonest;
235198 int
236199 has_reserved_this_job(conn c, job j)
237200 {
238 return j && j->state == JOB_STATE_RESERVED && j->reserver == c;
201 return j && j->r.state == Reserved && j->reserver == c;
239202 }
240203
241204 /* return true if c has a reserved job with less than one second until its
243206 int
244207 conn_has_close_deadline(conn c)
245208 {
246 usec t = now_usec();
209 int64 t = nanoseconds();
247210 job j = soonest_job(c);
248211
249 return j && t >= j->deadline_at - SAFETY_MARGIN;
212 return j && t >= j->r.deadline_at - SAFETY_MARGIN;
250213 }
251214
252215 int
255218 size_t i;
256219
257220 for (i = 0; i < c->watch.used; i++) {
258 if (((tube) c->watch.items[i])->ready.used) return 1;
221 if (((tube) c->watch.items[i])->ready.len) return 1;
259222 }
260223 return 0;
261224 }
262225
226
227 int
228 connless(conn a, conn b)
229 {
230 return a->tickat < b->tickat;
231 }
232
233
234 void
235 connrec(conn c, int i)
236 {
237 c->tickpos = i;
238 }
239
240
263241 void
264242 conn_close(conn c)
265243 {
266 event_del(&c->evq);
267
268 close(c->fd);
244 sockwant(&c->sock, 0);
245 close(c->sock.fd);
246 if (verbose) {
247 printf("close %d\n", c->sock.fd);
248 }
269249
270250 job_free(c->in_job);
271251
272252 /* was this a peek or stats command? */
273 if (c->out_job && !c->out_job->id) job_free(c->out_job);
253 if (c->out_job && !c->out_job->r.id) job_free(c->out_job);
274254
275255 c->in_job = c->out_job = NULL;
276256 c->in_job_read = 0;
280260
281261 cur_conn_ct--; /* stats */
282262
283 unbrake(NULL);
284263 remove_waiting_conn(c);
285264 conn_remove(c);
286265 if (has_reserved_job(c)) enqueue_reserved_jobs(c);
289268 c->use->using_ct--;
290269 TUBE_ASSIGN(c->use, NULL);
291270
292 conn_free(c);
293 }
271 if (c->tickpos > -1) {
272 heapremove(&c->srv->conns, c->tickpos);
273 }
274
275 free(c);
276 }
+0
-103
conn.h less more
0 /* conn.h - network connection state */
1
2 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef conn_h
19 #define conn_h
20
21 #include <sys/types.h>
22 #include <event.h>
23 #include "ms.h"
24 #include "tube.h"
25 #include "job.h"
26
27 /* A command can be at most LINE_BUF_SIZE chars, including "\r\n". This value
28 * MUST be enough to hold the longest possible command or reply line, which is
29 * currently "USING a{200}\r\n". */
30 #define LINE_BUF_SIZE 208
31
32 /* CONN_TYPE_* are bit masks */
33 #define CONN_TYPE_PRODUCER 1
34 #define CONN_TYPE_WORKER 2
35 #define CONN_TYPE_WAITING 4
36
37 #define conn_waiting(c) ((c)->type & CONN_TYPE_WAITING)
38
39 typedef struct conn *conn;
40
41 struct conn {
42 conn prev, next; /* linked list of connections */
43 int fd;
44 char state;
45 char type;
46 struct event evq;
47 int pending_timeout;
48
49 /* we cannot share this buffer with the reply line because we might read in
50 * command line data for a subsequent command, and we need to store it
51 * here. */
52 char cmd[LINE_BUF_SIZE]; /* this string is NOT NUL-terminated */
53 int cmd_len;
54 int cmd_read;
55 const char *reply;
56 int reply_len;
57 int reply_sent;
58 char reply_buf[LINE_BUF_SIZE]; /* this string IS NUL-terminated */
59
60 /* A job to be read from the client. */
61 job in_job;
62
63 /* Memoization of the soonest job */
64 job soonest_job;
65
66 /* How many bytes of in_job->body have been read so far. If in_job is NULL
67 * while in_job_read is nonzero, we are in bit bucket mode and
68 * in_job_read's meaning is inverted -- then it counts the bytes that
69 * remain to be thrown away. */
70 int in_job_read;
71
72 job out_job;
73 int out_job_sent;
74 struct job reserved_jobs; /* doubly-linked list header */
75 tube use;
76 struct ms watch;
77 };
78
79 conn make_conn(int fd, char start_state, tube use, tube watch);
80
81 int conn_set_evq(conn c, const int events, evh handler);
82 int conn_update_evq(conn c, const int flags);
83
84 void conn_close(conn c);
85
86 conn conn_remove(conn c);
87 void conn_insert(conn head, conn c);
88
89 int count_cur_conns();
90 unsigned int count_tot_conns();
91 int count_cur_producers();
92 int count_cur_workers();
93
94 void conn_set_producer(conn c);
95 void conn_set_worker(conn c);
96
97 job soonest_job(conn c);
98 int has_reserved_this_job(conn c, job j);
99 int conn_has_close_deadline(conn c);
100 int conn_ready(conn c);
101
102 #endif /*conn_h*/
0 Copyright 2010, 2011 Keith Rarick
1
2 Permission is hereby granted, free of charge, to any person obtaining a copy
3 of this software and associated documentation files (the "Software"), to deal
4 in the Software without restriction, including without limitation the rights
5 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6 copies of the Software, and to permit persons to whom the Software is
7 furnished to do so, subject to the following conditions:
8
9 The above copyright notice and this permission notice shall be included in
10 all copies or substantial portions of the Software.
11
12 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
18 THE SOFTWARE.
0 /* CT - (Relatively) Easy Unit Testing for C */
1
2 #include <string.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <stdarg.h>
6 #include <sys/types.h>
7 #include <unistd.h>
8 #include <sys/wait.h>
9 #include <errno.h>
10 #include "internal.h"
11
12 static void die(int code, int err, const char *msg);
13 static int failed(int s);
14
15
16 void
17 ctrun(T *t, int i, void (*f)(void), const char *name)
18 {
19 pid_t pid;
20 int r;
21 FILE *out;
22
23 if (i % 10 == 0) {
24 if (i % 50 == 0) {
25 putchar('\n');
26 }
27 printf("%5d", i);
28 }
29
30 t->name = name;
31
32 out = tmpfile();
33 if (!out) die(1, errno, "tmpfile");
34 t->fd = fileno(out);
35
36 fflush(stdout);
37 fflush(stderr);
38
39 pid = fork();
40 if (pid < 0) {
41 die(1, errno, "fork");
42 } else if (!pid) {
43 r = dup2(t->fd, 1); // send stdout to tmpfile
44 if (r == -1) die(3, errno, "dup2");
45
46 r = close(t->fd);
47 if (r == -1) die(3, errno, "fclose");
48
49 r = dup2(1, 2); // send stderr to stdout
50 if (r < 0) die(3, errno, "dup2");
51
52 f();
53 exit(0);
54 }
55
56 r = waitpid(pid, &t->status, 0);
57 if (r != pid) die(3, errno, "wait");
58
59 if (!t->status) {
60 putchar('.');
61 } else if (failed(t->status)) {
62 putchar('F');
63 } else {
64 putchar('E');
65 }
66
67 fflush(stdout);
68 }
69
70
71 void
72 ctlogpn(char *p, int n, char *fmt, ...)
73 {
74 va_list arg;
75
76 printf("%s:%d: ", p, n);
77 va_start(arg, fmt);
78 vprintf(fmt, arg);
79 va_end(arg);
80 putchar('\n');
81 }
82
83 void
84 ctfail(void)
85 {
86 fflush(stdout);
87 fflush(stderr);
88 abort();
89 }
90
91
92 static int
93 failed(int s)
94 {
95 return WIFSIGNALED(s) && (WTERMSIG(s) == SIGABRT);
96 }
97
98
99 void
100 ctreport(T ts[], int n)
101 {
102 int i, r, s;
103 char buf[1024]; // arbitrary size
104 int cf = 0, ce = 0;
105
106 putchar('\n');
107 for (i = 0; i < n; i++) {
108 if (!ts[i].status) continue;
109
110 printf("\n%s: ", ts[i].name);
111 if (failed(ts[i].status)) {
112 cf++;
113 printf("failure");
114 } else {
115 ce++;
116 printf("error");
117 if (WIFEXITED(ts[i].status)) {
118 printf(" (exit status %d)", WEXITSTATUS(ts[i].status));
119 }
120 if (WIFSIGNALED(ts[i].status)) {
121 printf(" (signal %d)", WTERMSIG(ts[i].status));
122 }
123 }
124
125 putchar('\n');
126 lseek(ts[i].fd, 0, SEEK_SET);
127 while ((r = read(ts[i].fd, buf, sizeof(buf)))) {
128 s = fwrite(buf, 1, r, stdout);
129 if (r != s) die(3, errno, "fwrite");
130 }
131 }
132
133 printf("\n%d tests; %d failures; %d errors.\n", n, cf, ce);
134 exit(cf || ce);
135 }
136
137
138 static void
139 die(int code, int err, const char *msg)
140 {
141 putc('\n', stderr);
142
143 if (msg && *msg) {
144 fputs(msg, stderr);
145 fputs(": ", stderr);
146 }
147
148 fputs(strerror(err), stderr);
149 putc('\n', stderr);
150 exit(code);
151 }
0 void ctfail(void);
1 void ctlogpn(char*, int, char*, ...);
2 #define ctlog(...) ctlogpn(__FILE__, __LINE__, __VA_ARGS__)
3 #define assert(x) do if (!(x)) {\
4 ctlog("test: " #x);\
5 ctfail();\
6 } while (0)
7 #define assertf(x, ...) do if (!(x)) {\
8 ctlog("test: " #x);\
9 ctlog(__VA_ARGS__);\
10 ctfail();\
11 } while (0)
0 #!/bin/sh
1
2 set -e
3
4 fixsyms() {
5 if test "`uname -s|tr A-Z a-z`" = darwin
6 then egrep -v [.]eh$ | egrep ^_ | sed s/^_//
7 else cat
8 fi
9 }
10
11 tests() {
12 for f in "$@"
13 do nm $f
14 done | cut -d ' ' -f 3 | fixsyms | egrep ^cttest
15 }
16
17 ts=`tests "$@" || (echo >&2 no tests found; exit 1)`
18
19 gen() {
20 printf '#include "internal.h"\n'
21 printf '\n'
22
23 i=0
24 for t in "$@"
25 do
26 printf 'extern void %s(void);\n' $t
27 i=`expr $i + 1`
28 done
29
30 printf '\nint\nmain(int argc, char *argv[])\n{\n'
31
32 printf ' T ts[%d] = {};\n' $i
33
34 i=0
35 for t in "$@"
36 do
37 printf ' ctrun(&ts[%d], %d, %s, "%s");\n' $i $i $t $t
38 i=`expr $i + 1`
39 done
40
41 printf ' ctreport(ts, %d);\n' $i
42 printf ' return 0;\n'
43 printf '}\n'
44 }
45
46 gen $ts
0 typedef struct T T;
1
2
3 struct T {
4 int status, fd;
5 const char *name;
6 };
7
8
9 void ctreport(T ts[], int n);
10 void ctrun(T *t, int i, void(*f)(void), const char *name);
+0
-289
cut.c less more
0 /*
1 * libcut.inc
2 * CUT 2.1
3 *
4 * Copyright (c) 2001-2002 Samuel A. Falvo II, William D. Tanksley
5 * See CUT-LICENSE.TXT for details.
6 *
7 * Based on WDT's 'TestAssert' package.
8 *
9 * $log$
10 */
11
12 #include <string.h>
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <stdarg.h>
16 #include <unistd.h>
17 #include <sys/wait.h>
18 #include <errno.h>
19 #include "cut.h"
20
21
22 #define BUF_SIZE 1024
23
24 #ifndef BOOL /* Just in case -- helps in portability */
25 #define BOOL int
26 #endif
27
28 #ifndef FALSE
29 #define FALSE (0)
30 #endif
31
32 #ifndef TRUE
33 #define TRUE 1
34 #endif
35
36 typedef struct test_output *test_output;
37
38 struct test_output {
39 test_output next;
40 int status;
41 const char *desc;
42 const char *group_name;
43 const char *test_name;
44 FILE *file;
45 };
46
47 static int breakpoint = 0;
48 static int count = 0, count_failures = 0, count_errors = 0;
49 static cut_fn cur_takedown = 0;
50 static test_output problem_reports = 0;
51 static const char *program;
52
53 static void
54 die(int code, const char *fmt, ...)
55 {
56 va_list v;
57
58 putc('\n', stderr);
59
60 va_start(v, fmt);
61 vfprintf(stderr, fmt, v);
62 va_end(v);
63
64 if (fmt && *fmt) fputs(": ", stderr);
65 fprintf(stderr, "%s\n", strerror(errno));
66 exit(code);
67 }
68
69 /* I/O Functions */
70
71 static void print_string( char *string )
72 {
73 printf( "%s", string );
74 fflush( stdout );
75 }
76
77 static void print_string_as_error( char *filename, int lineNumber, char *string )
78 {
79 printf( " %s:%d: %s", filename, lineNumber, string );
80 fflush( stdout );
81 }
82
83 static void print_integer( int i )
84 {
85 printf( "%d", i );
86 fflush( stdout );
87 }
88
89 static void print_integer_in_field( int i, int width )
90 {
91 printf( "%*d", width, i );
92 fflush( stdout );
93 }
94
95 static void new_line( void )
96 {
97 printf( "\n" );
98 fflush( stdout );
99 }
100
101 static void print_character( char ch )
102 {
103 printf( "%c", ch );
104 fflush( stdout );
105 }
106
107 /* CUT Initialization and Takedown Functions */
108
109 void cut_init(const char *prog_name, int brkpoint )
110 {
111 breakpoint = brkpoint;
112 count = 0;
113 program = prog_name;
114
115 if( brkpoint >= 0 )
116 {
117 print_string( "Breakpoint at test " );
118 print_integer( brkpoint );
119 new_line();
120 }
121 }
122
123 void cut_exit( void )
124 {
125 int r, s;
126 char buf[BUF_SIZE];
127 test_output to;
128
129 printf("\n");
130 for (to = problem_reports; to; to = to->next) {
131 printf("\n%s in %s/%s", to->desc, to->group_name, to->test_name);
132 if (!WIFEXITED(to->status) || (WEXITSTATUS(to->status) != 255)) {
133 if (WIFEXITED(to->status)) {
134 printf(" (Exit Status %d)", WEXITSTATUS(to->status));
135 }
136 if (WIFSIGNALED(to->status)) {
137 printf(" (Signal %d)", WTERMSIG(to->status));
138 }
139 }
140 printf("\n");
141 rewind(to->file);
142 while ((r = fread(buf, 1, BUF_SIZE, to->file))) {
143 s = fwrite(buf, 1, r, stdout);
144 if (r != s) die(3, "fwrite");
145 }
146 }
147
148 printf("\n%d tests; %d failures; %d errors.\n", count, count_failures,
149 count_errors);
150 exit(!!(count_failures + count_errors));
151 }
152
153 /* Test Progress Accounting functions */
154
155 static void
156 cut_mark_point(char out, char *filename, int lineNumber )
157 {
158 if ((count % 10) == 0) {
159 if ((count % 50) == 0) new_line();
160 print_integer_in_field( count, 5 );
161 }
162
163 print_character(out);
164 count++;
165
166 if( count == breakpoint )
167 {
168 print_string_as_error( filename, lineNumber, "Breakpoint hit" );
169 new_line();
170 cut_exit();
171 }
172 }
173
174
175 void __cut_assert(
176 char *filename,
177 int lineNumber,
178 char *message,
179 char *expression,
180 BOOL success
181 )
182 {
183 if (success) return;
184
185 print_string_as_error( filename, lineNumber, "(" );
186 print_string( expression );
187 print_string(") ");
188 print_string( message );
189 new_line();
190
191 if (cur_takedown) cur_takedown();
192 fflush(stdout);
193 fflush(stderr);
194 exit(-1);
195 }
196
197 typedef void(*collect_fn)(void *);
198
199 static FILE *
200 collect(pid_t *pid, collect_fn fn, void *data)
201 {
202 int r;
203 FILE *out;
204
205 out = tmpfile();
206 if (!out) return 0;
207
208 fflush(stdout);
209 fflush(stderr);
210
211 if ((*pid = fork())) {
212 if (*pid < 0) return 0;
213 return out;
214 } else {
215 r = dup2(fileno(out), fileno(stdout));
216 if (r < 0) die(3, "dup2");
217 r = fclose(out);
218 if (r) die(3, "fclose");
219 out = 0;
220
221 fn(data);
222 exit(0);
223 }
224 }
225
226 static void
227 run_in_child(void *data)
228 {
229 int r;
230 cut_fn *fns = data, bringup = fns[0], test = fns[1], takedown = fns[2];
231
232 r = dup2(fileno(stdout), fileno(stderr));
233 if (r < 0) die(3, "dup2");
234 bringup();
235 cur_takedown = takedown;
236 test();
237 takedown();
238 fflush(stdout);
239 fflush(stderr);
240 }
241
242 void
243 __cut_run(char *group_name, cut_fn bringup, cut_fn takedown, char *test_name,
244 cut_fn test, char *filename, int lineno)
245 {
246 pid_t pid = -1;
247 int status, r;
248 FILE *out;
249 test_output to;
250 char *problem_desc = 0;
251 cut_fn fns[3] = { bringup, test, takedown };
252
253 out = collect(&pid, run_in_child, fns);
254 if (!out) die(1, " %s:%d: collect", filename, lineno);
255 if (pid < 0) die(3, "fork");
256
257 r = waitpid(pid, &status, 0);
258 if (r != pid) die(3, "wait");
259
260 if (!status) {
261 cut_mark_point('.', filename, lineno );
262 } else if (WIFEXITED(status) && (WEXITSTATUS(status) == 255)) {
263 cut_mark_point('F', filename, lineno );
264 count_failures++;
265 problem_desc = "Failure";
266 } else {
267 cut_mark_point('E', filename, lineno );
268 count_errors++;
269 problem_desc = "Error";
270 }
271
272 if (!problem_desc) {
273 fclose(out);
274 return;
275 }
276
277 /* collect the output */
278 to = malloc(sizeof(struct test_output));
279 if (!to) die(3, "malloc");
280
281 to->desc = problem_desc;
282 to->status = status;
283 to->group_name = group_name;
284 to->test_name = test_name;
285 to->file = out;
286 to->next = problem_reports;
287 problem_reports = to;
288 }
+0
-58
cut.h less more
0 /*
1 * cut.h
2 * CUT 2.3
3 *
4 * Copyright (c) 2001 Samuel A. Falvo II, William D. Tanksley
5 * See CUT-LICENSE.TXT for details.
6 *
7 * Based on WDT's "TestAssert" package.
8 *
9 * $Log: cut.h,v $
10 * Revision 1.4 2003/03/18 05:53:50 sfalvo
11 * ADD: cutgen.c: cut_exit() -- common exit point; returns proper error code
12 * at all times.
13 *
14 * FIX: cutgen.c: Factored all instances of exit() to invoke cut_exit()
15 * instead. This fixes the bug #703793.
16 *
17 * Revision 1.3 2003/03/13 04:27:54 sfalvo
18 * ADD: LICENSE.TXT -- zlib license
19 *
20 * ADD: README cut.h cutgen.c -- Changelog token for CVS
21 *
22 * FIX: test/bringup-failure -- reflects new usage for bringups and
23 * teardowns in CUT 2.2.
24 *
25 */
26
27 #ifndef CUT_CUT_H_INCLUDED
28 #define CUT_CUT_H_INCLUDED
29
30 typedef void(*cut_fn)(void);
31
32 void cut_init(const char *, int);
33 void cut_exit(void);
34
35 #define cut_run(G, T) __cut_run("group-" #G, \
36 __CUT_BRINGUP__ ## G, \
37 __CUT_TAKEDOWN__ ## G, \
38 #T, \
39 __CUT__ ## T, \
40 __FILE__, \
41 __LINE__);
42
43 #define ASSERT(X,msg) __cut_assert(__FILE__,__LINE__,msg,#X,X)
44
45 #define STATIC_ASSERT(X) extern bool __static_ASSERT_at_line_##__LINE__##__[ (0!=(X))*2-1 ];
46
47 /*
48 * These functions are not officially "public". They exist here because they
49 * need to be for proper operation of CUT. Please use the aforementioned
50 * macros instead.
51 */
52
53 void __cut_run(char *, cut_fn, cut_fn, char *, cut_fn, char *, int);
54 void __cut_assert( char *, int, char *, char *, int );
55
56 #endif
57
+0
-410
cutgen.c less more
0 /*
1 * This file has been modified from the original CUT distribution.
2 *
3 * CUT 2.3-kr1
4 * Copyright (c) 2001-2002 Samuel A. Falvo II, William D. Tanksley
5 * See CUT-LICENSE.TXT for details.
6 *
7 * $Log: cutgen.c,v $
8 * Revision 1.4 2003/03/18 05:53:50 sfalvo
9 * ADD: cutgen.c: cut_exit() -- common exit point; returns proper error code
10 * at all times.
11 *
12 * FIX: cutgen.c: Factored all instances of exit() to invoke cut_exit()
13 * instead. This fixes the bug #703793.
14 *
15 * Revision 1.3 2003/03/13 04:27:54 sfalvo
16 * ADD: LICENSE.TXT -- zlib license
17 *
18 * ADD: README cut.h cutgen.c -- Changelog token for CVS
19 *
20 * FIX: test/bringup-failure -- reflects new usage for bringups and
21 * teardowns in CUT 2.2.
22 *
23 */
24
25 #include <stdio.h>
26 #include <string.h>
27 #include <stdlib.h>
28 #include <stdarg.h>
29
30 #include "util.h"
31
32 #define DO_NOT_PROCESS "..."
33
34 #define SEARCH_TOKEN_TEST "__CUT__"
35 #define SEARCH_TOKEN_BRINGUP "__CUT_BRINGUP__"
36 #define SEARCH_TOKEN_TAKEDOWN "__CUT_TAKEDOWN__"
37
38 #define MAX_SYMBOL_LENGTH 256 /* arbitrary */
39 #define MAX_LINE_LENGTH 1024 /* arbitrary */
40
41 #define SEARCH_TOKEN_TEST_LENGTH sizeof( SEARCH_TOKEN_TEST )-1
42 #define SEARCH_TOKEN_BRINGUP_LENGTH sizeof( SEARCH_TOKEN_BRINGUP )-1
43
44 #define terr(fmt, args...) do { fprintf(stderr, "\n"); twarn(fmt, ##args); exit(1); } while (0)
45 #define terrx(fmt, args...) do { fprintf(stderr, "\n"); twarnx(fmt, ##args); exit(1); } while (0)
46
47 typedef enum TestType {
48 TYPE_TEST = 0,
49 TYPE_BRINGUP = 1,
50 } TestType;
51
52 typedef struct TestItem {
53 char name[MAX_SYMBOL_LENGTH];
54 struct TestItem *next;
55 } TestItem;
56
57 typedef struct TestGroup {
58 char name[MAX_SYMBOL_LENGTH];
59 struct TestItem *tests;
60 struct TestGroup *next;
61 } TestGroup;
62
63 /* globals */
64
65 TestGroup *test_groups = 0;
66 FILE *outfile;
67
68 static int g_count, g_ready, g_index; /* Used by filename globbing support for windows */
69 static char **g_wildcards, g_fileName[MAX_LINE_LENGTH];
70
71 int NameAndTypeInTestList( char *name, TestType type )
72 {
73 TestItem *item;
74 TestGroup *group;
75
76 for (group = test_groups; group; group = group->next) {
77 if (!strcmp(group->name, name) && type == TYPE_BRINGUP) return 1;
78 for (item = group->tests; item; item = item->next) {
79 if (!strcmp(item->name, name)) return 1;
80 }
81 }
82
83 return 0;
84 }
85
86 void AppendToTestList( char *name, TestType type )
87 {
88 TestGroup *cur;
89 TestItem *newt;
90
91 if (type == TYPE_BRINGUP) {
92 struct TestGroup *new;
93
94 new = malloc(sizeof(struct TestGroup));
95 if (!new) terr("malloc");
96
97 new->tests = 0;
98 new->next = test_groups;
99 strcpy(new->name, name);
100 test_groups = new;
101 } else {
102 cur = test_groups;
103 if (!cur) terrx("no current test group");
104
105 newt = malloc(sizeof(struct TestItem));
106 if (!newt) terr("malloc");
107
108 newt->next = cur->tests;
109 strcpy(newt->name, name);
110 cur->tests = newt;
111 }
112 }
113
114 void InsertNameAndTypeIntoTestList( char *name, TestType type )
115 {
116 if ( !NameAndTypeInTestList( name, type ) )
117 AppendToTestList( name, type );
118 }
119
120 int CharacterIsDigit(char ch)
121 {
122 return ( ( ch >= '0') && ( ch <= '9' ) );
123 }
124
125 int CharacterIsUppercase(char ch)
126 {
127 return ( ( ch >= 'A' ) && ( ch <= 'Z' ) );
128 }
129
130 int CharacterIsLowercase(char ch)
131 {
132 return ( ( ch >= 'a' ) && ( ch <= 'z' ) );
133 }
134
135 int CharacterIsAlphabetic(char ch)
136 {
137 return CharacterIsUppercase(ch) || CharacterIsLowercase(ch) || ( ch == '_' );
138 }
139
140 int CharacterIsAlphanumeric( char ch )
141 {
142 return CharacterIsDigit(ch) || CharacterIsAlphabetic(ch);
143 }
144
145 void ProcessGenericFunction( char *line, int position,
146 TestType type, int tokenDisplacement )
147 {
148 char name[MAX_SYMBOL_LENGTH] = "";
149 int maxLength = strlen( line ) - 1, offset=0;
150 position = position + tokenDisplacement;
151
152 while ( CharacterIsAlphanumeric(line[position])
153 && (position<maxLength) && (offset<MAX_SYMBOL_LENGTH) )
154 {
155 name[offset++] = line[position++];
156 name[offset] = 0;
157 }
158
159 InsertNameAndTypeIntoTestList( name, type );
160 }
161
162 void ProcessBringupFunction( char *line, int position )
163 {
164 ProcessGenericFunction( line, position, TYPE_BRINGUP, SEARCH_TOKEN_BRINGUP_LENGTH );
165 }
166
167 void ProcessTestFunction( char *line, int position )
168 {
169 ProcessGenericFunction( line, position, TYPE_TEST, SEARCH_TOKEN_TEST_LENGTH );
170 }
171
172
173 int OffsetOfSubstring( char *line, char *token )
174 {
175 char *inset = strstr(line,token);
176
177 if ( !inset ) return -1;
178 else return inset - line;
179 }
180
181 void CallIfSubstringFound( char *line, char *token, void (*function)(char*,int) )
182 {
183 int index = OffsetOfSubstring( line, token );
184 if ( index != -1 )
185 function( line, index );
186 }
187
188 void ProcessSourceFile( char *filename )
189 {
190 FILE *source;
191 char line[MAX_LINE_LENGTH];
192
193 if( strcmp( filename, DO_NOT_PROCESS ) != 0 )
194 {
195
196 source = fopen(filename,"r");
197
198 while ( fgets(line,MAX_LINE_LENGTH,source) )
199 {
200 CallIfSubstringFound( line, SEARCH_TOKEN_BRINGUP, ProcessBringupFunction );
201 CallIfSubstringFound( line, SEARCH_TOKEN_TEST, ProcessTestFunction );
202 }
203
204 fclose(source);
205 }
206 }
207
208 void EmitExternDeclarationFor( char *name, char *prefix )
209 {
210 fprintf( outfile, "extern void %s%s( void );\n", prefix, name );
211 }
212
213 void Emit(char *text)
214 {
215 fprintf(outfile, "%s\n", text);
216 }
217
218 void BlankLine()
219 {
220 Emit( "" );
221 }
222
223 void ListExternalFunctions()
224 {
225 TestGroup *cur;
226 TestItem *item;
227
228 for (cur = test_groups; cur; cur = cur->next) {
229 EmitExternDeclarationFor(cur->name, SEARCH_TOKEN_BRINGUP);
230 EmitExternDeclarationFor(cur->name, SEARCH_TOKEN_TAKEDOWN);
231 for (item = cur->tests; item; item = item->next) {
232 EmitExternDeclarationFor(item->name, SEARCH_TOKEN_TEST);
233 }
234 }
235 BlankLine();
236 }
237
238 void ListHeaderFiles(void)
239 {
240 Emit(
241 "#include <string.h>\n"
242 "#include <stdlib.h>\n"
243 "#include <stdio.h>\n"
244 "#include <stdarg.h>\n"
245 "#include \"cut.h\"\n"
246 );
247 BlankLine();
248 BlankLine();
249 }
250
251 void EmitIndented(int indent,char *format, ...)
252 {
253 va_list v;
254 /* Print two spaces per level of indentation. */
255 fprintf( outfile, "%*s", indent*2, "" );
256
257 va_start(v,format);
258 vfprintf( outfile, format, v );
259 va_end(v);
260
261 fprintf( outfile, "\n" );
262 }
263
264 void EmitUnitTesterBody()
265 {
266 TestItem *test;
267 TestGroup *group;
268
269 Emit( "int main( int argc, char *argv[] )\n{" );
270 Emit( " if ( argc == 1 )" );
271 Emit( " cut_init(argv[0], -1 );" );
272 Emit( " else cut_init(argv[0], atoi( argv[1] ) );" );
273 BlankLine();
274
275 for (group = test_groups; group; group = group->next) {
276 for (test = group->tests; test; test = test->next) {
277 EmitIndented(1, "cut_run(%s, %s);", group->name, test->name);
278 }
279 }
280
281 BlankLine();
282 Emit( " cut_exit();\n" );
283 Emit( " return 0;\n}\n" );
284 }
285
286 void EmitCutCheck()
287 {
288 Emit( "/* Automatically generated: DO NOT MODIFY. */" );
289 ListHeaderFiles();
290 BlankLine();
291 ListExternalFunctions();
292 BlankLine();
293 EmitUnitTesterBody();
294 }
295
296 void FileName( char *base )
297 {
298 strncpy( g_fileName, base, MAX_LINE_LENGTH );
299 g_fileName[ MAX_LINE_LENGTH - 1 ] = 0;
300 }
301
302 int LoadArgument( void )
303 {
304 if ( g_index >= g_count )
305 return 0;
306
307 FileName( g_wildcards[g_index] );
308 g_index++; /* MUST come after FileName() call; bad code smell */
309 return 1;
310 }
311
312 void StartArguments( int starting, int count, char *array[] )
313 {
314 g_index = starting;
315 g_count = count;
316 g_wildcards = array;
317
318 g_ready = LoadArgument();
319 }
320
321 int NextArgument( void )
322 {
323 if( g_ready )
324 g_ready = LoadArgument();
325
326 return g_ready;
327 }
328
329 char *GetArgument( void )
330 {
331 if( g_ready )
332 return g_fileName;
333
334 return NULL;
335 }
336
337 void EstablishOutputFile( int argc, char *argv[] )
338 {
339 int i;
340
341 i = 0;
342 while( i < argc )
343 {
344 if( ( argv[i+1] != NULL ) && ( strcmp( argv[i], "-o" ) == 0 ) )
345 {
346 outfile = fopen( argv[i+1], "wb+" );
347 if( outfile == NULL )
348 fprintf( stderr, "ERROR: Can't open %s for writing.\n", argv[i+1] );
349
350 argv[i] = argv[i+1] = DO_NOT_PROCESS;
351
352 return;
353 }
354
355 i++;
356 }
357
358 outfile = stdout;
359 }
360
361 int main( int argc,char *argv[] )
362 {
363 char *filename;
364
365 if ( argc < 2 )
366 {
367 fprintf(
368 stderr,
369 "USAGE:\n"
370 " %s [options] <input file> [<input file> [...]]\n"
371 "\n"
372 "OPTIONS:\n"
373 " -o filename Specifies output file.\n"
374 "\n"
375 "NOTES:\n"
376 " If -o is left unspecified, output defaults to stdout.\n",
377 argv[0]
378 );
379 return 3;
380 }
381
382 EstablishOutputFile( argc, argv );
383
384 /* Skip the executable's name and the output filename. */
385 StartArguments(0,argc,argv);
386
387 /* Consume the rest of the arguments, one at a time. */
388 while ( NextArgument() )
389 {
390 filename = GetArgument();
391
392 if( strcmp( filename, DO_NOT_PROCESS ) )
393 {
394 fprintf( stderr, " - parsing '%s'... ", filename);
395 ProcessSourceFile( filename );
396 fprintf( stderr, "done.\n");
397 }
398 }
399
400 EmitCutCheck();
401 fflush(outfile);
402 fclose(outfile);
403 return 0;
404 }
405
406 /*
407 * vim: tabstop=3 shiftwidth=3 expandtab
408 */
409
+386
-0
dat.h less more
0 typedef unsigned char uchar;
1 typedef uchar byte;
2 typedef unsigned int uint;
3 typedef int32_t int32;
4 typedef uint32_t uint32;
5 typedef int64_t int64;
6 typedef uint64_t uint64;
7
8 #define int8_t do_not_use_int8_t
9 #define uint8_t do_not_use_uint8_t
10 #define int32_t do_not_use_int32_t
11 #define uint32_t do_not_use_uint32_t
12 #define int64_t do_not_use_int64_t
13 #define uint64_t do_not_use_uint64_t
14
15 typedef struct ms *ms;
16 typedef struct job *job;
17 typedef struct tube *tube;
18 typedef struct conn *conn;
19 typedef struct Heap Heap;
20 typedef struct Jobrec Jobrec;
21 typedef struct File File;
22 typedef struct Socket Socket;
23 typedef struct Srv Srv;
24 typedef struct Wal Wal;
25
26 typedef void(*evh)(int, short, void *);
27 typedef void(*ms_event_fn)(ms a, void *item, size_t i);
28 typedef void(*Handle)(void*, int rw); // rw can also be 'h' for hangup
29 typedef int(*Less)(void*, void*);
30 typedef void(*Record)(void*, int);
31
32 #if _LP64
33 #define NUM_PRIMES 48
34 #else
35 #define NUM_PRIMES 19
36 #endif
37
38 #define MAX_TUBE_NAME_LEN 201
39
40 /* A command can be at most LINE_BUF_SIZE chars, including "\r\n". This value
41 * MUST be enough to hold the longest possible command or reply line, which is
42 * currently "USING a{200}\r\n". */
43 #define LINE_BUF_SIZE 208
44
45 /* CONN_TYPE_* are bit masks */
46 #define CONN_TYPE_PRODUCER 1
47 #define CONN_TYPE_WORKER 2
48 #define CONN_TYPE_WAITING 4
49
50 #define min(a,b) ((a)<(b)?(a):(b))
51
52 #define twarn(fmt, args...) warn("%s:%d in %s: " fmt, \
53 __FILE__, __LINE__, __func__, ##args)
54 #define twarnx(fmt, args...) warnx("%s:%d in %s: " fmt, \
55 __FILE__, __LINE__, __func__, ##args)
56
57 #define URGENT_THRESHOLD 1024
58 #define JOB_DATA_SIZE_LIMIT_DEFAULT ((1 << 16) - 1)
59
60 extern const char version[];
61 extern int verbose;
62
63 struct stats {
64 uint urgent_ct;
65 uint waiting_ct;
66 uint buried_ct;
67 uint reserved_ct;
68 uint pause_ct;
69 uint64 total_delete_ct;
70 uint64 total_jobs_ct;
71 };
72
73
74 struct Heap {
75 int cap;
76 int len;
77 void **data;
78 Less less;
79 Record rec;
80 };
81 int heapinsert(Heap *h, void *x);
82 void* heapremove(Heap *h, int k);
83
84
85 struct Socket {
86 int fd;
87 Handle f;
88 void *x;
89 int added;
90 };
91
92 void sockinit(Handle tick, void *x, int64 ns);
93 int sockwant(Socket *s, int rw);
94 void sockmain(void); // does not return
95
96 struct ms {
97 size_t used, cap, last;
98 void **items;
99 ms_event_fn oninsert, onremove;
100 };
101
102 enum
103 {
104 Walver = 7
105 };
106
107 enum // Jobrec.state
108 {
109 Invalid,
110 Ready,
111 Reserved,
112 Buried,
113 Delayed,
114 Copy
115 };
116
117 // if you modify this struct, you must increment Walver above
118 struct Jobrec {
119 uint64 id;
120 uint32 pri;
121 int64 delay;
122 int64 ttr;
123 int32 body_size;
124 int64 created_at;
125 int64 deadline_at;
126 uint32 reserve_ct;
127 uint32 timeout_ct;
128 uint32 release_ct;
129 uint32 bury_ct;
130 uint32 kick_ct;
131 byte state;
132 };
133
134 struct job {
135 Jobrec r; // persistent fields; these get written to the wal
136
137 /* bookeeping fields; these are in-memory only */
138 char pad[6];
139 tube tube;
140 job prev, next; /* linked list of jobs */
141 job ht_next; /* Next job in a hash table list */
142 size_t heap_index; /* where is this job in its current heap */
143 File *file;
144 job fnext;
145 job fprev;
146 void *reserver;
147 int walresv;
148 int walused;
149
150 char body[]; // written separately to the wal
151 };
152
153 struct tube {
154 uint refs;
155 char name[MAX_TUBE_NAME_LEN];
156 Heap ready;
157 Heap delay;
158 struct ms waiting; /* set of conns */
159 struct stats stat;
160 uint using_ct;
161 uint watching_ct;
162 int64 pause;
163 int64 deadline_at;
164 struct job buried;
165 };
166
167 struct conn {
168 conn prev, next; /* linked list of connections */
169 Srv *srv;
170 Socket sock;
171 char state;
172 char type;
173 int rw; // currently want: 'r' or 'w'
174 int pending_timeout;
175 int64 tickat; // time at which to do more work
176 int tickpos; // position in srv->conns
177
178 /* we cannot share this buffer with the reply line because we might read in
179 * command line data for a subsequent command, and we need to store it
180 * here. */
181 char cmd[LINE_BUF_SIZE]; /* this string is NOT NUL-terminated */
182 int cmd_len;
183 int cmd_read;
184 const char *reply;
185 int reply_len;
186 int reply_sent;
187 char reply_buf[LINE_BUF_SIZE]; /* this string IS NUL-terminated */
188
189 /* A job to be read from the client. */
190 job in_job;
191
192 /* Memoization of the soonest job */
193 job soonest_job;
194
195 /* How many bytes of in_job->body have been read so far. If in_job is NULL
196 * while in_job_read is nonzero, we are in bit bucket mode and
197 * in_job_read's meaning is inverted -- then it counts the bytes that
198 * remain to be thrown away. */
199 int in_job_read;
200
201 job out_job;
202 int out_job_sent;
203 tube use;
204 struct ms watch;
205 struct job reserved_jobs; /* doubly-linked list header */
206 };
207
208
209 void v(void);
210
211 void warn(const char *fmt, ...);
212 void warnx(const char *fmt, ...);
213 char* fmtalloc(char *fmt, ...);
214 void* zalloc(int n);
215 #define new(T) zalloc(sizeof(T))
216
217 extern const char *progname;
218
219 int64 nanoseconds(void);
220 int falloc(int fd, int len);
221
222
223 void ms_init(ms a, ms_event_fn oninsert, ms_event_fn onremove);
224 void ms_clear(ms a);
225 int ms_append(ms a, void *item);
226 int ms_remove(ms a, void *item);
227 int ms_contains(ms a, void *item);
228 void *ms_take(ms a);
229
230
231 #define make_job(pri,delay,ttr,body_size,tube) make_job_with_id(pri,delay,ttr,body_size,tube,0)
232
233 job allocate_job(int body_size);
234 job make_job_with_id(uint pri, int64 delay, int64 ttr,
235 int body_size, tube tube, uint64 id);
236 void job_free(job j);
237
238 /* Lookup a job by job ID */
239 job job_find(uint64 job_id);
240
241 /* the void* parameters are really job pointers */
242 void job_setheappos(void*, int);
243 int job_pri_less(void*, void*);
244 int job_delay_less(void*, void*);
245
246 job job_copy(job j);
247
248 const char * job_state(job j);
249
250 int job_list_any_p(job head);
251 job job_remove(job j);
252 void job_insert(job head, job j);
253
254 uint64 total_jobs(void);
255
256 /* for unit tests */
257 size_t get_all_jobs_used(void);
258
259
260 extern struct ms tubes;
261
262 tube make_tube(const char *name);
263 void tube_dref(tube t);
264 void tube_iref(tube t);
265 tube tube_find(const char *name);
266 tube tube_find_or_make(const char *name);
267 #define TUBE_ASSIGN(a,b) (tube_dref(a), (a) = (b), tube_iref(a))
268
269
270 conn make_conn(int fd, char start_state, tube use, tube watch);
271
272 int connless(conn a, conn b);
273 void connrec(conn c, int i);
274 void connwant(conn c, const int mask, conn list);
275 void connsched(conn c);
276
277 void conn_close(conn c);
278
279 conn conn_remove(conn c);
280 void conn_insert(conn head, conn c);
281
282 int count_cur_conns(void);
283 uint count_tot_conns(void);
284 int count_cur_producers(void);
285 int count_cur_workers(void);
286
287 void conn_set_producer(conn c);
288 void conn_set_worker(conn c);
289
290 job soonest_job(conn c);
291 int has_reserved_this_job(conn c, job j);
292 int conn_has_close_deadline(conn c);
293 int conn_ready(conn c);
294
295 #define conn_waiting(c) ((c)->type & CONN_TYPE_WAITING)
296
297
298 extern size_t primes[];
299
300
301 extern size_t job_data_size_limit;
302
303 void prot_init(void);
304 void prottick(Srv *s);
305
306 conn remove_waiting_conn(conn c);
307
308 void enqueue_reserved_jobs(conn c);
309
310 void enter_drain_mode(int sig);
311 void h_accept(const int fd, const short which, Srv* srv);
312 void prot_remove_tube(tube t);
313 void prot_replay(Srv *s, job list);
314
315
316 int make_server_socket(char *host_addr, char *port);
317
318
319 enum
320 {
321 Filesizedef = (10 << 20)
322 };
323
324 struct Wal {
325 int use;
326 char *dir;
327 File *head;
328 File *cur;
329 File *tail;
330 int nfile;
331 int next;
332 int filesz;
333 int resv; // bytes reserved
334 int alive; // bytes in use
335 int64 nmig; // migrations
336 int64 nrec; // records written ever
337 int wantsync;
338 int64 syncrate;
339 int64 lastsync;
340 int nocomp; // disable binlog compaction?
341 };
342 int waldirlock(Wal*);
343 void walinit(Wal*, job list);
344 int walwrite(Wal*, job);
345 void walmaint(Wal*);
346 int walresvput(Wal*, job);
347 int walresvupdate(Wal*, job);
348 void walgc(Wal*);
349
350
351 struct File {
352 File *next;
353 uint refs;
354 int seq;
355 int iswopen; // is open for writing
356 int fd;
357 int free;
358 int resv;
359 char *path;
360 Wal *w;
361
362 struct job jlist; // jobs written in this file
363 };
364 int fileinit(File*, Wal*, int);
365 Wal* fileadd(File*, Wal*);
366 void fileincref(File*);
367 void filedecref(File*);
368 void fileaddjob(File*, job);
369 void filermjob(File*, job);
370 int fileread(File*, job list);
371 void filewopen(File*);
372 void filewclose(File*);
373 int filewrjobshort(File*, job);
374 int filewrjobfull(File*, job);
375
376
377 struct Srv {
378 Socket sock;
379 Heap conns;
380 Wal wal;
381 };
382 void srv(Srv *srv);
383 void srvaccept(Srv *s, int ev);
384 void srvschedconn(Srv *srv, conn c);
385 void srvtick(Srv *s, int ev);
2222 .TP
2323 .B \-d
2424 Detach and run beanstalkd as a daemon.
25 .TP
26 .B \-V
27 Increase verbosity. May be used more than once to produce even more
28 verbose output. The output format is subject to change.
2529 .TP
2630 .B \-f <ms>
2731 Call
244244
245245 The delete command removes a job from the server entirely. It is normally used
246246 by the client when the job has successfully run to completion. A client can
247 delete jobs that it has reserved, ready jobs, and jobs that are buried. The
248 delete command looks like this:
247 delete jobs that it has reserved, ready jobs, delayed jobs, and jobs that are
248 buried. The delete command looks like this:
249249
250250 delete <id>\r\n
251251
430430 reserved or delayed. If the job is reserved and this amount of time
431431 elapses before its state changes, it is considered to have timed out.
432432
433 - "file" is the number of the earliest binlog file containing this job.
434 If -b wasn't used, this will be 0.
435
433436 - "reserves" is the number of times this job has been reserved.
434437
435438 - "timeouts" is the number of times this job has timed out during a
477480
478481 - "current-jobs-buried" is the number of buried jobs in this tube.
479482
480 - "total-jobs" is the cumulative count of jobs created in this tube.
483 - "total-jobs" is the cumulative count of jobs created in this tube in
484 the current beanstalkd process.
481485
482486 - "current-waiting" is the number of open connections that have issued a
483487 reserve command while watching this tube but not yet received a response.
484488
485489 - "pause" is the number of seconds the tube has been paused for.
486490
491 - "cmd-delete" is the cumulative number of delete commands for this tube
492
487493 - "cmd-pause-tube" is the cumulative number of pause-tube commands for this
488494 tube.
489495
505511 is a YAML file with statistical information represented a dictionary.
506512
507513 The stats data for the system is a YAML file representing a single dictionary
508 of strings to scalars. It contains these keys:
514 of strings to scalars. Entries described as "cumulative" are reset when the
515 beanstalkd process starts; they are not stored on disk with the -b flag.
509516
510517 - "current-jobs-urgent" is the number of ready jobs with priority < 1024.
511518
583590
584591 - "version" is the version string of the server.
585592
586 - "rusage-utime" is the accumulated user CPU time of this process in seconds
593 - "rusage-utime" is the cumulative user CPU time of this process in seconds
587594 and microseconds.
588595
589 - "rusage-stime" is the accumulated system CPU time of this process in
596 - "rusage-stime" is the cumulative system CPU time of this process in
590597 seconds and microseconds.
591598
592 - "uptime" is the number of seconds since this server started running.
599 - "uptime" is the number of seconds since this server process started running.
593600
594601 - "binlog-oldest-index" is the index of the oldest binlog file needed to
595602 store the current jobs
600607 - "binlog-max-size" is the maximum size in bytes a binlog file is allowed
601608 to get before a new binlog file is opened
602609
610 - "binlog-records-written" is the cumulative number of records written
611 to the binlog
612
613 - "binlog-records-migrated" is the cumulative number of records written
614 as part of compaction
615
603616 The list-tubes command returns a list of all existing tubes. Its form is:
604617
605618 list-tubes\r\n
0 #include <stdint.h>
1 #include <inttypes.h>
2 #include <stddef.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <unistd.h>
6 #include <stdarg.h>
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <fcntl.h>
10 #include <errno.h>
11 #include <string.h>
12 #include "dat.h"
13
14 static void warnpos(File*, int, char*, ...);
15 static int readrec(File*, job, int*);
16 static int readrec5(File*, job, int*);
17 static int readfull(File*, void*, int, int*, char*);
18
19 enum
20 {
21 Walver5 = 5
22 };
23
24 typedef struct Jobrec5 Jobrec5;
25
26 struct Jobrec5 {
27 uint64 id;
28 uint32 pri;
29 uint64 delay; // usec
30 uint64 ttr; // usec
31 int32 body_size;
32 uint64 created_at; // usec
33 uint64 deadline_at; // usec
34 uint32 reserve_ct;
35 uint32 timeout_ct;
36 uint32 release_ct;
37 uint32 bury_ct;
38 uint32 kick_ct;
39 byte state;
40
41 char pad[1];
42 };
43
44 enum
45 {
46 Jobrec5size = offsetof(Jobrec5, pad)
47 };
48
49 void
50 fileincref(File *f)
51 {
52 if (!f) return;
53 f->refs++;
54 }
55
56
57 void
58 filedecref(File *f)
59 {
60 if (!f) return;
61 f->refs--;
62 if (f->refs < 1) {
63 walgc(f->w);
64 }
65 }
66
67
68 void
69 fileaddjob(File *f, job j)
70 {
71 job h;
72
73 h = &f->jlist;
74 if (!h->fprev) h->fprev = h;
75 j->file = f;
76 j->fprev = h->fprev;
77 j->fnext = h;
78 h->fprev->fnext = j;
79 h->fprev = j;
80 fileincref(f);
81 }
82
83
84 void
85 filermjob(File *f, job j)
86 {
87 if (!f) return;
88 if (f != j->file) return;
89 j->fnext->fprev = j->fprev;
90 j->fprev->fnext = j->fnext;
91 j->fnext = 0;
92 j->fprev = 0;
93 j->file = NULL;
94 f->w->alive -= j->walused;
95 j->walused = 0;
96 filedecref(f);
97 }
98
99
100 // Fileread reads jobs from f->path into list.
101 // It returns 0 on success, or 1 if any errors occurred.
102 int
103 fileread(File *f, job list)
104 {
105 int err = 0, v;
106
107 if (!readfull(f, &v, sizeof(v), &err, "version")) {
108 return err;
109 }
110 switch (v) {
111 case Walver:
112 fileincref(f);
113 while (readrec(f, list, &err));
114 filedecref(f);
115 return err;
116 case Walver5:
117 fileincref(f);
118 while (readrec5(f, list, &err));
119 filedecref(f);
120 return err;
121 }
122
123 warnx("%s: unknown version: %d", f->path, v);
124 return 1;
125 }
126
127
128 // Readrec reads a record from f->fd into linked list l.
129 // If an error occurs, it sets *err to 1.
130 // Readrec returns the number of records read, either 1 or 0.
131 static int
132 readrec(File *f, job l, int *err)
133 {
134 int r, sz = 0;
135 int namelen;
136 Jobrec jr;
137 job j;
138 tube t;
139 char tubename[MAX_TUBE_NAME_LEN];
140
141 r = read(f->fd, &namelen, sizeof(int));
142 if (r == -1) {
143 twarn("read");
144 warnpos(f, 0, "error");
145 *err = 1;
146 return 0;
147 }
148 if (r != sizeof(int)) {
149 return 0;
150 }
151 sz += r;
152 if (namelen >= MAX_TUBE_NAME_LEN) {
153 warnpos(f, -r, "namelen %d exceeds maximum of %d", namelen, MAX_TUBE_NAME_LEN - 1);
154 *err = 1;
155 return 0;
156 }
157
158 if (namelen) {
159 r = readfull(f, tubename, namelen, err, "tube name");
160 if (!r) {
161 return 0;
162 }
163 sz += r;
164 }
165 tubename[namelen] = '\0';
166
167 r = readfull(f, &jr, sizeof(Jobrec), err, "job struct");
168 if (!r) {
169 return 0;
170 }
171 sz += r;
172
173 // are we reading trailing zeroes?
174 if (!jr.id) return 0;
175
176 j = job_find(jr.id);
177 if (!(j || namelen)) {
178 // We read a short record without having seen a
179 // full record for this job, so the full record
180 // was in an eariler file that has been deleted.
181 // Therefore the job itself has either been
182 // deleted or migrated; either way, this record
183 // should be ignored.
184 return 1;
185 }
186
187 switch (jr.state) {
188 case Reserved:
189 jr.state = Ready;
190 case Ready:
191 case Buried:
192 case Delayed:
193 if (!j) {
194 t = tube_find_or_make(tubename);
195 j = make_job_with_id(jr.pri, jr.delay, jr.ttr, jr.body_size,
196 t, jr.id);
197 j->next = j->prev = j;
198 j->r.created_at = jr.created_at;
199 }
200 j->r = jr;
201 job_insert(l, j);
202
203 // full record; read the job body
204 if (namelen) {
205 if (jr.body_size != j->r.body_size) {
206 warnpos(f, -r, "job %"PRIu64" size changed", j->r.id);
207 warnpos(f, -r, "was %zu, now %zu", j->r.body_size, jr.body_size);
208 goto Error;
209 }
210 r = readfull(f, j->body, j->r.body_size, err, "job body");
211 if (!r) {
212 goto Error;
213 }
214 sz += r;
215
216 // since this is a full record, we can move
217 // the file pointer and decref the old
218 // file, if any
219 filermjob(j->file, j);
220 fileaddjob(f, j);
221 }
222 j->walused += sz;
223 f->w->alive += sz;
224
225 return 1;
226 case Invalid:
227 if (j) {
228 job_remove(j);
229 filermjob(j->file, j);
230 job_free(j);
231 }
232 return 1;
233 }
234
235 Error:
236 *err = 1;
237 if (j) {
238 job_remove(j);
239 filermjob(j->file, j);
240 job_free(j);
241 }
242 return 0;
243 }
244
245
246 // Readrec5 is like readrec, but it reads a record in "version 5"
247 // of the log format.
248 static int
249 readrec5(File *f, job l, int *err)
250 {
251 int r, sz = 0;
252 size_t namelen;
253 Jobrec5 jr;
254 job j;
255 tube t;
256 char tubename[MAX_TUBE_NAME_LEN];
257
258 r = read(f->fd, &namelen, sizeof(namelen));
259 if (r == -1) {
260 twarn("read");
261 warnpos(f, 0, "error");
262 *err = 1;
263 return 0;
264 }
265 if (r != sizeof(namelen)) {
266 return 0;
267 }
268 sz += r;
269 if (namelen >= MAX_TUBE_NAME_LEN) {
270 warnpos(f, -r, "namelen %d exceeds maximum of %d", namelen, MAX_TUBE_NAME_LEN - 1);
271 *err = 1;
272 return 0;
273 }
274
275 if (namelen) {
276 r = readfull(f, tubename, namelen, err, "v5 tube name");
277 if (!r) {
278 return 0;
279 }
280 sz += r;
281 }
282 tubename[namelen] = '\0';
283
284 r = readfull(f, &jr, Jobrec5size, err, "v5 job struct");
285 if (!r) {
286 return 0;
287 }
288 sz += r;
289
290 // are we reading trailing zeroes?
291 if (!jr.id) return 0;
292
293 j = job_find(jr.id);
294 if (!(j || namelen)) {
295 // We read a short record without having seen a
296 // full record for this job, so the full record
297 // was in an eariler file that has been deleted.
298 // Therefore the job itself has either been
299 // deleted or migrated; either way, this record
300 // should be ignored.
301 return 1;
302 }
303
304 switch (jr.state) {
305 case Reserved:
306 jr.state = Ready;
307 case Ready:
308 case Buried:
309 case Delayed:
310 if (!j) {
311 t = tube_find_or_make(tubename);
312 j = make_job_with_id(jr.pri, jr.delay, jr.ttr, jr.body_size,
313 t, jr.id);
314 j->next = j->prev = j;
315 j->r.created_at = jr.created_at;
316 }
317 j->r.id = jr.id;
318 j->r.pri = jr.pri;
319 j->r.delay = jr.delay * 1000; // us => ns
320 j->r.ttr = jr.ttr * 1000; // us => ns
321 j->r.body_size = jr.body_size;
322 j->r.created_at = jr.created_at * 1000; // us => ns
323 j->r.deadline_at = jr.deadline_at * 1000; // us => ns
324 j->r.reserve_ct = jr.reserve_ct;
325 j->r.timeout_ct = jr.timeout_ct;
326 j->r.release_ct = jr.release_ct;
327 j->r.bury_ct = jr.bury_ct;
328 j->r.kick_ct = jr.kick_ct;
329 j->r.state = jr.state;
330 job_insert(l, j);
331
332 // full record; read the job body
333 if (namelen) {
334 if (jr.body_size != j->r.body_size) {
335 warnpos(f, -r, "job %"PRIu64" size changed", j->r.id);
336 warnpos(f, -r, "was %zu, now %zu", j->r.body_size, jr.body_size);
337 goto Error;
338 }
339 r = readfull(f, j->body, j->r.body_size, err, "v5 job body");
340 if (!r) {
341 goto Error;
342 }
343 sz += r;
344
345 // since this is a full record, we can move
346 // the file pointer and decref the old
347 // file, if any
348 filermjob(j->file, j);
349 fileaddjob(f, j);
350 }
351 j->walused += sz;
352 f->w->alive += sz;
353
354 return 1;
355 case Invalid:
356 if (j) {
357 job_remove(j);
358 filermjob(j->file, j);
359 job_free(j);
360 }
361 return 1;
362 }
363
364 Error:
365 *err = 1;
366 if (j) {
367 job_remove(j);
368 filermjob(j->file, j);
369 job_free(j);
370 }
371 return 0;
372 }
373
374
375 static int
376 readfull(File *f, void *c, int n, int *err, char *desc)
377 {
378 int r;
379
380 r = read(f->fd, c, n);
381 if (r == -1) {
382 twarn("read");
383 warnpos(f, 0, "error reading %s", desc);
384 *err = 1;
385 return 0;
386 }
387 if (r != n) {
388 warnpos(f, -r, "unexpected EOF reading %d bytes (got %d): %s", n, r, desc);
389 *err = 1;
390 return 0;
391 }
392 return r;
393 }
394
395
396 static void
397 warnpos(File *f, int adj, char *fmt, ...)
398 {
399 int off;
400 va_list ap;
401
402 off = lseek(f->fd, 0, SEEK_CUR);
403 fprintf(stderr, "%s:%u: ", f->path, off+adj);
404 va_start(ap, fmt);
405 vfprintf(stderr, fmt, ap);
406 va_end(ap);
407 fputc('\n', stderr);
408 }
409
410
411 // Opens f for writing, writes a header, and initializes
412 // f->free and f->resv.
413 // Sets f->iswopen if successful.
414 void
415 filewopen(File *f)
416 {
417 int fd, r;
418 int n;
419 int ver = Walver;
420
421 fd = open(f->path, O_WRONLY|O_CREAT, 0400);
422 if (fd < 0) {
423 twarn("open %s", f->path);
424 return;
425 }
426
427 r = falloc(fd, f->w->filesz);
428 if (r) {
429 close(fd);
430 errno = r;
431 twarn("Cannot allocate space for file %s", f->path);
432 return;
433 }
434
435 n = write(fd, &ver, sizeof(int));
436 if (n < sizeof(int)) {
437 twarn("write %s", f->path);
438 close(fd);
439 return;
440 }
441
442 f->fd = fd;
443 f->iswopen = 1;
444 fileincref(f);
445 f->free = f->w->filesz - n;
446 f->resv = 0;
447 }
448
449
450 static int
451 filewrite(File *f, job j, void *buf, int len)
452 {
453 int r;
454
455 r = write(f->fd, buf, len);
456 if (r != len) {
457 twarn("write");
458 return 0;
459 }
460
461 f->w->resv -= r;
462 f->resv -= r;
463 j->walresv -= r;
464 j->walused += r;
465 f->w->alive += r;
466 return 1;
467 }
468
469
470 int
471 filewrjobshort(File *f, job j)
472 {
473 int r, nl;
474
475 nl = 0; // name len 0 indicates short record
476 r = filewrite(f, j, &nl, sizeof nl) &&
477 filewrite(f, j, &j->r, sizeof j->r);
478 if (!r) return 0;
479
480 if (j->r.state == Invalid) {
481 filermjob(j->file, j);
482 }
483
484 return r;
485 }
486
487
488 int
489 filewrjobfull(File *f, job j)
490 {
491 int nl;
492
493 fileaddjob(f, j);
494 nl = strlen(j->tube->name);
495 return
496 filewrite(f, j, &nl, sizeof nl) &&
497 filewrite(f, j, j->tube->name, nl) &&
498 filewrite(f, j, &j->r, sizeof j->r) &&
499 filewrite(f, j, j->body, j->r.body_size);
500 }
501
502
503 void
504 filewclose(File *f)
505 {
506 if (!f) return;
507 if (!f->iswopen) return;
508 if (f->free) {
509 (void)ftruncate(f->fd, f->w->filesz - f->free);
510 }
511 close(f->fd);
512 f->iswopen = 0;
513 filedecref(f);
514 }
515
516
517 int
518 fileinit(File *f, Wal *w, int n)
519 {
520 f->w = w;
521 f->seq = n;
522 f->path = fmtalloc("%s/binlog.%d", w->dir, n);
523 return !!f->path;
524 }
525
526
527 // Adds f to the linked list in w,
528 // updating w->tail and w->head as necessary.
529 Wal*
530 fileadd(File *f, Wal *w)
531 {
532 if (w->tail) {
533 w->tail->next = f;
534 }
535 w->tail = f;
536 if (!w->head) {
537 w->head = f;
538 }
539 w->nfile++;
540 return w;
541 }
0 #include <stdint.h>
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <sys/time.h>
5 #include "ct/ct.h"
6 #include "dat.h"
7
8
9 void
10 cttestheap_insert_one()
11 {
12 Heap h = {0};
13 job j;
14
15 h.less = job_pri_less;
16 h.rec = job_setheappos;
17
18 j = make_job(1, 0, 1, 0, 0);
19 assertf(j, "allocate job");
20
21 heapinsert(&h, j);
22 assertf(h.len == 1, "h should contain one item.");
23 assertf(j->heap_index == 0, "should match");
24 }
25
26
27 void
28 cttestheap_insert_and_remove_one()
29 {
30 Heap h = {0};
31 int r;
32 job j, j1;
33
34 h.less = job_pri_less;
35 h.rec = job_setheappos;
36 j1 = make_job(1, 0, 1, 0, 0);
37 assertf(j1, "allocate job");
38
39 r = heapinsert(&h, j1);
40 assertf(r, "insert should succeed");
41
42 j = heapremove(&h, 0);
43 assertf(j == j1, "j1 should come back out");
44 assertf(h.len == 0, "h should be empty.");
45 printf("j->heap_index is %zu\n", j->heap_index);
46 assertf(j->heap_index == -1, "j's heap index should be invalid");
47 }
48
49
50 void
51 cttestheap_priority()
52 {
53 Heap h = {0};
54 int r;
55 job j, j1, j2, j3;
56
57 h.less = job_pri_less;
58 h.rec = job_setheappos;
59 j1 = make_job(1, 0, 1, 0, 0);
60 j2 = make_job(2, 0, 1, 0, 0);
61 j3 = make_job(3, 0, 1, 0, 0);
62 assertf(j1, "allocate job");
63 assertf(j2, "allocate job");
64 assertf(j3, "allocate job");
65
66 r = heapinsert(&h, j2);
67 assertf(r, "insert should succeed");
68 assertf(j2->heap_index == 0, "should match");
69
70 r = heapinsert(&h, j3);
71 assertf(r, "insert should succeed");
72 assertf(j2->heap_index == 0, "should match");
73 assertf(j3->heap_index == 1, "should match");
74
75 r = heapinsert(&h, j1);
76 assertf(r, "insert should succeed");
77 assertf(j1->heap_index == 0, "should match");
78 assertf(j2->heap_index == 2, "should match");
79 assertf(j3->heap_index == 1, "should match");
80
81 j = heapremove(&h, 0);
82 assertf(j == j1, "j1 should come out first.");
83 assertf(j2->heap_index == 0, "should match");
84 assertf(j3->heap_index == 1, "should match");
85
86 j = heapremove(&h, 0);
87 assertf(j == j2, "j2 should come out second.");
88 assertf(j3->heap_index == 0, "should match");
89
90 j = heapremove(&h, 0);
91 assertf(j == j3, "j3 should come out third.");
92 }
93
94
95 void
96 cttestheap_fifo_property()
97 {
98 Heap h = {0};
99 int r;
100 job j, j3a, j3b, j3c;
101
102 h.less = job_pri_less;
103 h.rec = job_setheappos;
104 j3a = make_job(3, 0, 1, 0, 0);
105 j3b = make_job(3, 0, 1, 0, 0);
106 j3c = make_job(3, 0, 1, 0, 0);
107 assertf(j3a, "allocate job");
108 assertf(j3b, "allocate job");
109 assertf(j3c, "allocate job");
110
111 r = heapinsert(&h, j3a);
112 assertf(r, "insert should succeed");
113 assertf(h.data[0] == j3a, "j3a should be in pos 0");
114 assertf(j3a->heap_index == 0, "should match");
115
116 r = heapinsert(&h, j3b);
117 assertf(r, "insert should succeed");
118 assertf(h.data[1] == j3b, "j3b should be in pos 1");
119 assertf(j3a->heap_index == 0, "should match");
120 assertf(j3b->heap_index == 1, "should match");
121
122 r = heapinsert(&h, j3c);
123 assertf(r, "insert should succeed");
124 assertf(h.data[2] == j3c, "j3c should be in pos 2");
125 assertf(j3a->heap_index == 0, "should match");
126 assertf(j3b->heap_index == 1, "should match");
127 assertf(j3c->heap_index == 2, "should match");
128
129 j = heapremove(&h, 0);
130 assertf(j == j3a, "j3a should come out first.");
131 assertf(j3b->heap_index == 0, "should match");
132 assertf(j3c->heap_index == 1, "should match");
133
134 j = heapremove(&h, 0);
135 assertf(j == j3b, "j3b should come out second.");
136 assertf(j3c->heap_index == 0, "should match");
137
138 j = heapremove(&h, 0);
139 assertf(j == j3c, "j3c should come out third.");
140 }
141
142
143 void
144 cttestheap_many_jobs()
145 {
146 Heap h = {0};
147 uint last_pri;
148 int r, i, n = 20;
149 job j;
150
151 h.less = job_pri_less;
152 h.rec = job_setheappos;
153
154 for (i = 0; i < n; i++) {
155 j = make_job(1 + rand() % 8192, 0, 1, 0, 0);
156 assertf(j, "allocation");
157 r = heapinsert(&h, j);
158 assertf(r, "heapinsert");
159 }
160
161 last_pri = 0;
162 for (i = 0; i < n; i++) {
163 j = heapremove(&h, 0);
164 assertf(j->r.pri >= last_pri, "should come out in order");
165 last_pri = j->r.pri;
166 }
167 }
168
169
170 void
171 cttestheap_remove_k()
172 {
173 Heap h = {0};
174 uint last_pri;
175 int r, i, c, n = 20;
176 job j;
177
178 h.less = job_pri_less;
179 h.rec = job_setheappos;
180
181 for (c = 0; c < 50; c++) {
182 for (i = 0; i < n; i++) {
183 j = make_job(1 + rand() % 8192, 0, 1, 0, 0);
184 assertf(j, "allocation");
185 r = heapinsert(&h, j);
186 assertf(r, "heapinsert");
187 }
188
189 /* remove one from the middle */
190 heapremove(&h, 25);
191
192 /* now make sure the rest are still a valid heap */
193 last_pri = 0;
194 for (i = 1; i < n; i++) {
195 j = heapremove(&h, 0);
196 assertf(j->r.pri >= last_pri, "should come out in order");
197 last_pri = j->r.pri;
198 }
199 }
200 }
0 #include <stdint.h>
1 #include <stdlib.h>
2 #include <string.h>
3 #include "dat.h"
4
5
6 static void
7 set(Heap *h, int k, void *x)
8 {
9 h->data[k] = x;
10 h->rec(x, k);
11 }
12
13
14 static void
15 swap(Heap *h, int a, int b)
16 {
17 void *tmp;
18
19 tmp = h->data[a];
20 set(h, a, h->data[b]);
21 set(h, b, tmp);
22 }
23
24
25 static int
26 less(Heap *h, int a, int b)
27 {
28 return h->less(h->data[a], h->data[b]);
29 }
30
31
32 static void
33 siftdown(Heap *h, int k)
34 {
35 for (;;) {
36 int p = (k-1) / 2; /* parent */
37
38 if (k == 0 || less(h, p, k)) {
39 return;
40 }
41
42 swap(h, k, p);
43 k = p;
44 }
45 }
46
47
48 static void
49 siftup(Heap *h, int k)
50 {
51 for (;;) {
52 int l, r, s;
53
54 l = k*2 + 1; /* left child */
55 r = k*2 + 2; /* right child */
56
57 /* find the smallest of the three */
58 s = k;
59 if (l < h->len && less(h, l, s)) s = l;
60 if (r < h->len && less(h, r, s)) s = r;
61
62 if (s == k) {
63 return; /* satisfies the heap property */
64 }
65
66 swap(h, k, s);
67 k = s;
68 }
69 }
70
71
72 // Heapinsert inserts x into heap h according to h->less.
73 // It returns 1 on success, otherwise 0.
74 int
75 heapinsert(Heap *h, void *x)
76 {
77 int k;
78
79 if (h->len == h->cap) {
80 void **ndata;
81 int ncap = (h->len+1) * 2; /* allocate twice what we need */
82
83 ndata = malloc(sizeof(void*) * ncap);
84 if (!ndata) {
85 return 0;
86 }
87
88 memcpy(ndata, h->data, sizeof(void*)*h->len);
89 free(h->data);
90 h->data = ndata;
91 h->cap = ncap;
92 }
93
94 k = h->len;
95 h->len++;
96 set(h, k, x);
97 siftdown(h, k);
98 return 1;
99 }
100
101
102 void *
103 heapremove(Heap *h, int k)
104 {
105 void *x;
106
107 if (k >= h->len) {
108 return 0;
109 }
110
111 x = h->data[k];
112 h->len--;
113 set(h, k, h->data[h->len]);
114 siftdown(h, k);
115 siftup(h, k);
116 h->rec(x, -1);
117 return x;
118 }
+0
-520
install-sh less more
0 #!/bin/sh
1 # install - install a program, script, or datafile
2
3 scriptversion=2009-04-28.21; # UTC
4
5 # This originates from X11R5 (mit/util/scripts/install.sh), which was
6 # later released in X11R6 (xc/config/util/install.sh) with the
7 # following copyright and license.
8 #
9 # Copyright (C) 1994 X Consortium
10 #
11 # Permission is hereby granted, free of charge, to any person obtaining a copy
12 # of this software and associated documentation files (the "Software"), to
13 # deal in the Software without restriction, including without limitation the
14 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
15 # sell copies of the Software, and to permit persons to whom the Software is
16 # furnished to do so, subject to the following conditions:
17 #
18 # The above copyright notice and this permission notice shall be included in
19 # all copies or substantial portions of the Software.
20 #
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
25 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
26 # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #
28 # Except as contained in this notice, the name of the X Consortium shall not
29 # be used in advertising or otherwise to promote the sale, use or other deal-
30 # ings in this Software without prior written authorization from the X Consor-
31 # tium.
32 #
33 #
34 # FSF changes to this file are in the public domain.
35 #
36 # Calling this script install-sh is preferred over install.sh, to prevent
37 # `make' implicit rules from creating a file called install from it
38 # when there is no Makefile.
39 #
40 # This script is compatible with the BSD install script, but was written
41 # from scratch.
42
43 nl='
44 '
45 IFS=" "" $nl"
46
47 # set DOITPROG to echo to test this script
48
49 # Don't use :- since 4.3BSD and earlier shells don't like it.
50 doit=${DOITPROG-}
51 if test -z "$doit"; then
52 doit_exec=exec
53 else
54 doit_exec=$doit
55 fi
56
57 # Put in absolute file names if you don't have them in your path;
58 # or use environment vars.
59
60 chgrpprog=${CHGRPPROG-chgrp}
61 chmodprog=${CHMODPROG-chmod}
62 chownprog=${CHOWNPROG-chown}
63 cmpprog=${CMPPROG-cmp}
64 cpprog=${CPPROG-cp}
65 mkdirprog=${MKDIRPROG-mkdir}
66 mvprog=${MVPROG-mv}
67 rmprog=${RMPROG-rm}
68 stripprog=${STRIPPROG-strip}
69
70 posix_glob='?'
71 initialize_posix_glob='
72 test "$posix_glob" != "?" || {
73 if (set -f) 2>/dev/null; then
74 posix_glob=
75 else
76 posix_glob=:
77 fi
78 }
79 '
80
81 posix_mkdir=
82
83 # Desired mode of installed file.
84 mode=0755
85
86 chgrpcmd=
87 chmodcmd=$chmodprog
88 chowncmd=
89 mvcmd=$mvprog
90 rmcmd="$rmprog -f"
91 stripcmd=
92
93 src=
94 dst=
95 dir_arg=
96 dst_arg=
97
98 copy_on_change=false
99 no_target_directory=
100
101 usage="\
102 Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
103 or: $0 [OPTION]... SRCFILES... DIRECTORY
104 or: $0 [OPTION]... -t DIRECTORY SRCFILES...
105 or: $0 [OPTION]... -d DIRECTORIES...
106
107 In the 1st form, copy SRCFILE to DSTFILE.
108 In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
109 In the 4th, create DIRECTORIES.
110
111 Options:
112 --help display this help and exit.
113 --version display version info and exit.
114
115 -c (ignored)
116 -C install only if different (preserve the last data modification time)
117 -d create directories instead of installing files.
118 -g GROUP $chgrpprog installed files to GROUP.
119 -m MODE $chmodprog installed files to MODE.
120 -o USER $chownprog installed files to USER.
121 -s $stripprog installed files.
122 -t DIRECTORY install into DIRECTORY.
123 -T report an error if DSTFILE is a directory.
124
125 Environment variables override the default commands:
126 CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
127 RMPROG STRIPPROG
128 "
129
130 while test $# -ne 0; do
131 case $1 in
132 -c) ;;
133
134 -C) copy_on_change=true;;
135
136 -d) dir_arg=true;;
137
138 -g) chgrpcmd="$chgrpprog $2"
139 shift;;
140
141 --help) echo "$usage"; exit $?;;
142
143 -m) mode=$2
144 case $mode in
145 *' '* | *' '* | *'
146 '* | *'*'* | *'?'* | *'['*)
147 echo "$0: invalid mode: $mode" >&2
148 exit 1;;
149 esac
150 shift;;
151
152 -o) chowncmd="$chownprog $2"
153 shift;;
154
155 -s) stripcmd=$stripprog;;
156
157 -t) dst_arg=$2
158 shift;;
159
160 -T) no_target_directory=true;;
161
162 --version) echo "$0 $scriptversion"; exit $?;;
163
164 --) shift
165 break;;
166
167 -*) echo "$0: invalid option: $1" >&2
168 exit 1;;
169
170 *) break;;
171 esac
172 shift
173 done
174
175 if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
176 # When -d is used, all remaining arguments are directories to create.
177 # When -t is used, the destination is already specified.
178 # Otherwise, the last argument is the destination. Remove it from $@.
179 for arg
180 do
181 if test -n "$dst_arg"; then
182 # $@ is not empty: it contains at least $arg.
183 set fnord "$@" "$dst_arg"
184 shift # fnord
185 fi
186 shift # arg
187 dst_arg=$arg
188 done
189 fi
190
191 if test $# -eq 0; then
192 if test -z "$dir_arg"; then
193 echo "$0: no input file specified." >&2
194 exit 1
195 fi
196 # It's OK to call `install-sh -d' without argument.
197 # This can happen when creating conditional directories.
198 exit 0
199 fi
200
201 if test -z "$dir_arg"; then
202 trap '(exit $?); exit' 1 2 13 15
203
204 # Set umask so as not to create temps with too-generous modes.
205 # However, 'strip' requires both read and write access to temps.
206 case $mode in
207 # Optimize common cases.
208 *644) cp_umask=133;;
209 *755) cp_umask=22;;
210
211 *[0-7])
212 if test -z "$stripcmd"; then
213 u_plus_rw=
214 else
215 u_plus_rw='% 200'
216 fi
217 cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
218 *)
219 if test -z "$stripcmd"; then
220 u_plus_rw=
221 else
222 u_plus_rw=,u+rw
223 fi
224 cp_umask=$mode$u_plus_rw;;
225 esac
226 fi
227
228 for src
229 do
230 # Protect names starting with `-'.
231 case $src in
232 -*) src=./$src;;
233 esac
234
235 if test -n "$dir_arg"; then
236 dst=$src
237 dstdir=$dst
238 test -d "$dstdir"
239 dstdir_status=$?
240 else
241
242 # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
243 # might cause directories to be created, which would be especially bad
244 # if $src (and thus $dsttmp) contains '*'.
245 if test ! -f "$src" && test ! -d "$src"; then
246 echo "$0: $src does not exist." >&2
247 exit 1
248 fi
249
250 if test -z "$dst_arg"; then
251 echo "$0: no destination specified." >&2
252 exit 1
253 fi
254
255 dst=$dst_arg
256 # Protect names starting with `-'.
257 case $dst in
258 -*) dst=./$dst;;
259 esac
260
261 # If destination is a directory, append the input filename; won't work
262 # if double slashes aren't ignored.
263 if test -d "$dst"; then
264 if test -n "$no_target_directory"; then
265 echo "$0: $dst_arg: Is a directory" >&2
266 exit 1
267 fi
268 dstdir=$dst
269 dst=$dstdir/`basename "$src"`
270 dstdir_status=0
271 else
272 # Prefer dirname, but fall back on a substitute if dirname fails.
273 dstdir=`
274 (dirname "$dst") 2>/dev/null ||
275 expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
276 X"$dst" : 'X\(//\)[^/]' \| \
277 X"$dst" : 'X\(//\)$' \| \
278 X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
279 echo X"$dst" |
280 sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
281 s//\1/
282 q
283 }
284 /^X\(\/\/\)[^/].*/{
285 s//\1/
286 q
287 }
288 /^X\(\/\/\)$/{
289 s//\1/
290 q
291 }
292 /^X\(\/\).*/{
293 s//\1/
294 q
295 }
296 s/.*/./; q'
297 `
298
299 test -d "$dstdir"
300 dstdir_status=$?
301 fi
302 fi
303
304 obsolete_mkdir_used=false
305
306 if test $dstdir_status != 0; then
307 case $posix_mkdir in
308 '')
309 # Create intermediate dirs using mode 755 as modified by the umask.
310 # This is like FreeBSD 'install' as of 1997-10-28.
311 umask=`umask`
312 case $stripcmd.$umask in
313 # Optimize common cases.
314 *[2367][2367]) mkdir_umask=$umask;;
315 .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
316
317 *[0-7])
318 mkdir_umask=`expr $umask + 22 \
319 - $umask % 100 % 40 + $umask % 20 \
320 - $umask % 10 % 4 + $umask % 2
321 `;;
322 *) mkdir_umask=$umask,go-w;;
323 esac
324
325 # With -d, create the new directory with the user-specified mode.
326 # Otherwise, rely on $mkdir_umask.
327 if test -n "$dir_arg"; then
328 mkdir_mode=-m$mode
329 else
330 mkdir_mode=
331 fi
332
333 posix_mkdir=false
334 case $umask in
335 *[123567][0-7][0-7])
336 # POSIX mkdir -p sets u+wx bits regardless of umask, which
337 # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
338 ;;
339 *)
340 tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
341 trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
342
343 if (umask $mkdir_umask &&
344 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
345 then
346 if test -z "$dir_arg" || {
347 # Check for POSIX incompatibilities with -m.
348 # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
349 # other-writeable bit of parent directory when it shouldn't.
350 # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
351 ls_ld_tmpdir=`ls -ld "$tmpdir"`
352 case $ls_ld_tmpdir in
353 d????-?r-*) different_mode=700;;
354 d????-?--*) different_mode=755;;
355 *) false;;
356 esac &&
357 $mkdirprog -m$different_mode -p -- "$tmpdir" && {
358 ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
359 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
360 }
361 }
362 then posix_mkdir=:
363 fi
364 rmdir "$tmpdir/d" "$tmpdir"
365 else
366 # Remove any dirs left behind by ancient mkdir implementations.
367 rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
368 fi
369 trap '' 0;;
370 esac;;
371 esac
372
373 if
374 $posix_mkdir && (
375 umask $mkdir_umask &&
376 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
377 )
378 then :
379 else
380
381 # The umask is ridiculous, or mkdir does not conform to POSIX,
382 # or it failed possibly due to a race condition. Create the
383 # directory the slow way, step by step, checking for races as we go.
384
385 case $dstdir in
386 /*) prefix='/';;
387 -*) prefix='./';;
388 *) prefix='';;
389 esac
390
391 eval "$initialize_posix_glob"
392
393 oIFS=$IFS
394 IFS=/
395 $posix_glob set -f
396 set fnord $dstdir
397 shift
398 $posix_glob set +f
399 IFS=$oIFS
400
401 prefixes=
402
403 for d
404 do
405 test -z "$d" && continue
406
407 prefix=$prefix$d
408 if test -d "$prefix"; then
409 prefixes=
410 else
411 if $posix_mkdir; then
412 (umask=$mkdir_umask &&
413 $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
414 # Don't fail if two instances are running concurrently.
415 test -d "$prefix" || exit 1
416 else
417 case $prefix in
418 *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
419 *) qprefix=$prefix;;
420 esac
421 prefixes="$prefixes '$qprefix'"
422 fi
423 fi
424 prefix=$prefix/
425 done
426
427 if test -n "$prefixes"; then
428 # Don't fail if two instances are running concurrently.
429 (umask $mkdir_umask &&
430 eval "\$doit_exec \$mkdirprog $prefixes") ||
431 test -d "$dstdir" || exit 1
432 obsolete_mkdir_used=true
433 fi
434 fi
435 fi
436
437 if test -n "$dir_arg"; then
438 { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
439 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
440 { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
441 test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
442 else
443
444 # Make a couple of temp file names in the proper directory.
445 dsttmp=$dstdir/_inst.$$_
446 rmtmp=$dstdir/_rm.$$_
447
448 # Trap to clean up those temp files at exit.
449 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
450
451 # Copy the file name to the temp name.
452 (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
453
454 # and set any options; do chmod last to preserve setuid bits.
455 #
456 # If any of these fail, we abort the whole thing. If we want to
457 # ignore errors from any of these, just make sure not to ignore
458 # errors from the above "$doit $cpprog $src $dsttmp" command.
459 #
460 { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
461 { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
462 { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
463 { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
464
465 # If -C, don't bother to copy if it wouldn't change the file.
466 if $copy_on_change &&
467 old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
468 new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
469
470 eval "$initialize_posix_glob" &&
471 $posix_glob set -f &&
472 set X $old && old=:$2:$4:$5:$6 &&
473 set X $new && new=:$2:$4:$5:$6 &&
474 $posix_glob set +f &&
475
476 test "$old" = "$new" &&
477 $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
478 then
479 rm -f "$dsttmp"
480 else
481 # Rename the file to the real destination.
482 $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
483
484 # The rename failed, perhaps because mv can't rename something else
485 # to itself, or perhaps because mv is so ancient that it does not
486 # support -f.
487 {
488 # Now remove or move aside any old file at destination location.
489 # We try this two ways since rm can't unlink itself on some
490 # systems and the destination file might be busy for other
491 # reasons. In this case, the final cleanup might fail but the new
492 # file should still install successfully.
493 {
494 test ! -f "$dst" ||
495 $doit $rmcmd -f "$dst" 2>/dev/null ||
496 { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
497 { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
498 } ||
499 { echo "$0: cannot unlink or rename $dst" >&2
500 (exit 1); exit 1
501 }
502 } &&
503
504 # Now rename the file to the real destination.
505 $doit $mvcmd "$dsttmp" "$dst"
506 }
507 fi || exit 1
508
509 trap '' 0
510 fi
511 done
512
513 # Local variables:
514 # eval: (add-hook 'write-file-hooks 'time-stamp)
515 # time-stamp-start: "scriptversion="
516 # time-stamp-format: "%:y-%02m-%02d.%02H"
517 # time-stamp-time-zone: "UTC"
518 # time-stamp-end: "; # UTC"
519 # End:
0 #include <stdint.h>
1 #include <stdlib.h>
2 #include <string.h>
3 #include <stdio.h>
4 #include <unistd.h>
5 #include <signal.h>
6 #include <sys/stat.h>
7 #include <sys/socket.h>
8 #include <sys/select.h>
9 #include <netdb.h>
10 #include <netinet/ip.h>
11 #include <arpa/inet.h>
12 #include <fcntl.h>
13 #include <sys/wait.h>
14 #include <errno.h>
15 #include "ct/ct.h"
16 #include "dat.h"
17
18 static void testsrv(char*, char*, int);
19 static void forksrv(int*, int*);
20 static int copy(int, int, int);
21 static int diff(char*, int);
22 static int diallocal(int);
23 static void cleanup(int sig);
24 static void mustsend(int fd, char* cmd);
25 static void ckresp(int fd, char* exp);
26 static void writefull(int fd, char *s, int n);
27 static void readfull(int fd, char *b, int n);
28
29 typedef struct T T;
30 struct T {
31 char *cmd;
32 char *exp;
33 };
34
35 static T ts[] = {
36 {"sh-tests/allow-underscore.commands", "sh-tests/allow-underscore.expected"},
37 {"sh-tests/delete_ready.commands", "sh-tests/delete_ready.expected"},
38 {"sh-tests/multi-tube.commands", "sh-tests/multi-tube.expected"},
39 {"sh-tests/no_negative_delays.commands", "sh-tests/no_negative_delays.expected"},
40 {"sh-tests/omit-time-left.commands", "sh-tests/omit-time-left.expected"},
41 {"sh-tests/pause-tube.commands", "sh-tests/pause-tube.expected"},
42 {"sh-tests/small_delay.commands", "sh-tests/small_delay.expected"},
43 {"sh-tests/stats_tube.commands", "sh-tests/stats_tube.expected"},
44 {"sh-tests/too-big.commands", "sh-tests/too-big.expected"},
45 {"sh-tests/ttr-large.commands", "sh-tests/ttr-large.expected"},
46 {"sh-tests/ttr-small.commands", "sh-tests/ttr-small.expected"},
47 {"sh-tests/zero_delay.commands", "sh-tests/zero_delay.expected"},
48 {},
49 };
50
51 static int srvpid;
52 static int timeout = 100*1000000; // 100ms
53
54
55 void
56 cttestsrv()
57 {
58 int i;
59
60 for (i = 0; ts[i].cmd; i++) {
61 testsrv(ts[i].cmd, ts[i].exp, 4096);
62 testsrv(ts[i].cmd, ts[i].exp, 1);
63 }
64 }
65
66
67 static void
68 testsrv(char *cmd, char *exp, int bufsiz)
69 {
70 int diffst, srvst, port = 0, cfd, tfd, diffpid;
71 struct sigaction sa = {};
72
73 job_data_size_limit = 10;
74
75 progname = cmd;
76 puts(cmd);
77 forksrv(&port, &srvpid);
78 if (port == -1 || srvpid == -1) {
79 puts("forksrv failed");
80 exit(1);
81 }
82
83 // Fail if this test takes more than 10 seconds.
84 // If we have trouble installing the timeout,
85 // just proceed anyway.
86 sa.sa_handler = cleanup;
87 sigaction(SIGALRM, &sa, 0);
88 alarm(10);
89
90 cfd = diallocal(port);
91 if (cfd == -1) {
92 twarn("diallocal");
93 kill(srvpid, 9);
94 exit(1);
95 }
96
97 tfd = open(cmd, O_RDONLY, 0);
98 if (tfd == -1) {
99 twarn("open");
100 kill(srvpid, 9);
101 exit(1);
102 }
103
104 if (copy(cfd, tfd, bufsiz) == -1) {
105 twarn("copy");
106 kill(srvpid, 9);
107 exit(1);
108 }
109
110 diffpid = diff(exp, cfd);
111 if (diffpid == -1) {
112 twarn("diff");
113 kill(srvpid, 9);
114 exit(1);
115 }
116
117 waitpid(diffpid, &diffst, 0);
118
119 // wait until after diff has finished to kill srvpid
120 kill(srvpid, 9);
121 waitpid(srvpid, &srvst, 0);
122 assertf(WIFSIGNALED(srvst) && WTERMSIG(srvst) == 9,
123 "status %d, signal %d",
124 WEXITSTATUS(srvst),
125 WTERMSIG(srvst));
126
127 assertf(diffst == 0, "was %d", diffst);
128 }
129
130
131 static void
132 killsrv(void)
133 {
134 if (srvpid > 1) {
135 kill(srvpid, 9);
136 }
137 }
138
139
140 void
141 cttestreservewithtimeout2conn()
142 {
143 int port = 0, cfd0, cfd1;
144 struct sigaction sa = {};
145
146 job_data_size_limit = 10;
147
148 progname = __func__;
149 forksrv(&port, &srvpid);
150 if (port == -1 || srvpid == -1) {
151 puts("forksrv failed");
152 exit(1);
153 }
154
155 atexit(killsrv);
156
157 // Fail if this test takes more than 10 seconds.
158 // If we have trouble installing the timeout,
159 // just proceed anyway.
160 sa.sa_handler = cleanup;
161 sigaction(SIGALRM, &sa, 0);
162 alarm(10);
163
164 cfd0 = diallocal(port);
165 if (cfd0 == -1) {
166 twarn("diallocal");
167 exit(1);
168 }
169
170 cfd1 = diallocal(port);
171 if (cfd1 == -1) {
172 twarn("diallocal");
173 exit(1);
174 }
175
176 mustsend(cfd0, "watch foo\r\n");
177 ckresp(cfd0, "WATCHING 2\r\n");
178 mustsend(cfd0, "reserve-with-timeout 1\r\n");
179 mustsend(cfd1, "watch foo\r\n");
180 ckresp(cfd1, "WATCHING 2\r\n");
181 timeout = 1100000000; // 1.1s
182 ckresp(cfd0, "TIMED_OUT\r\n");
183 }
184
185
186 static void
187 forksrv(int *port, int *pid)
188 {
189 int r, len;
190 Srv s = {};
191 struct sockaddr_in addr;
192
193 s.sock.fd = make_server_socket("127.0.0.1", "0");
194 if (s.sock.fd == -1) return;
195
196 len = sizeof(addr);
197 r = getsockname(s.sock.fd, (struct sockaddr*)&addr, (socklen_t*)&len);
198 if (r == -1 || len > sizeof(addr)) return;
199
200 *port = addr.sin_port;
201
202 *pid = fork();
203 if (*pid != 0) return;
204
205 /* now in child */
206
207 prot_init();
208
209 srv(&s); /* does not return */
210 exit(1); /* satisfy the compiler */
211 }
212
213
214 static int
215 diff(char *f0, int fd)
216 {
217 int pid;
218
219 pid = fork();
220 if (pid != 0) return pid;
221
222 /* now in child */
223
224 dup2(fd, 0);
225 close(fd);
226
227 execlp("diff", "diff", f0, "-", (char*)0);
228 /* not reached */
229 exit(1);
230 }
231
232
233 static int
234 copy(int dst, int src, int bs)
235 {
236 char buf[bs];
237 int r, w, c;
238
239 for (;;) {
240 r = read(src, buf, sizeof buf);
241 if (r == -1) return -1;
242 if (r == 0) break;
243
244 for (w = 0; w < r; w += c) {
245 c = write(dst, buf+w, r-w);
246 if (c == -1) return -1;
247 }
248 }
249 return 0;
250 }
251
252
253 static int
254 diallocal(int port)
255 {
256 int r, fd;
257 struct sockaddr_in addr = {};
258
259 addr.sin_family = AF_INET;
260 addr.sin_port = port;
261 r = inet_aton("127.0.0.1", &addr.sin_addr);
262 if (!r) {
263 errno = EINVAL;
264 return -1;
265 }
266
267 fd = socket(PF_INET, SOCK_STREAM, 0);
268 if (fd == -1) {
269 return -1;
270 }
271
272 r = connect(fd, (struct sockaddr*)&addr, sizeof addr);
273 if (r == -1) {
274 return -1;
275 }
276
277 return fd;
278 }
279
280
281 static void
282 cleanup(int sig)
283 {
284 puts("timed out");
285 if (srvpid > 0) {
286 kill(srvpid, 9);
287 }
288 exit(1);
289 }
290
291
292 static void
293 mustsend(int fd, char *s)
294 {
295 writefull(fd, s, strlen(s));
296 printf(">%d %s", fd, s);
297 fflush(stdout);
298 }
299
300
301 static void
302 writefull(int fd, char *s, int n)
303 {
304 int c;
305 for (; n; n -= c) {
306 c = write(fd, s, n);
307 if (c == -1) {
308 perror("write");
309 exit(1);
310 }
311 s += c;
312 }
313 }
314
315
316 static void
317 readfull(int fd, char *b, int n)
318 {
319 int r;
320 fd_set rfd;
321 struct timeval tv;
322
323 for (; n; n -= r) {
324 FD_ZERO(&rfd);
325 FD_SET(fd, &rfd);
326 tv.tv_sec = timeout / 1000000000;
327 tv.tv_usec = (timeout/1000) % 1000000;
328 r = select(fd+1, &rfd, (void*)0, (void*)0, &tv);
329 switch (r) {
330 case 1:
331 break;
332 case 0:
333 fputs("timeout", stderr);
334 exit(8);
335 case -1:
336 perror("select");
337 exit(1);
338 default:
339 fputs("unknown error", stderr);
340 exit(3);
341 }
342
343 r = read(fd, b, n);
344 if (r == -1) {
345 perror("write");
346 exit(1);
347 }
348 b += r;
349 }
350 }
351
352
353 static void
354 ckresp(int fd, char *exp)
355 {
356 printf("<%d ", fd);
357 fflush(stdout);
358 char c;
359 while (*exp) {
360 readfull(fd, &c, 1);
361 assert(c == *exp);
362 putc(c, stdout);
363 fflush(stdout);
364 exp++;
365 }
366 }
0 #include <stdint.h>
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <sys/time.h>
5 #include "ct/ct.h"
6 #include "dat.h"
7
8 static tube default_tube;
9
10 void
11 cttestjob_creation()
12 {
13 job j;
14
15 TUBE_ASSIGN(default_tube, make_tube("default"));
16 j = make_job(1, 0, 1, 0, default_tube);
17 assertf(j->r.pri == 1, "priority should match");
18 }
19
20 void
21 cttestjob_cmp_pris()
22 {
23 job a, b;
24
25 TUBE_ASSIGN(default_tube, make_tube("default"));
26 a = make_job(1, 0, 1, 0, default_tube);
27 b = make_job(1 << 27, 0, 1, 0, default_tube);
28
29 assertf(job_pri_less(a, b), "should be less");
30 }
31
32 void
33 cttestjob_cmp_ids()
34 {
35 job a, b;
36
37 TUBE_ASSIGN(default_tube, make_tube("default"));
38 a = make_job(1, 0, 1, 0, default_tube);
39 b = make_job(1, 0, 1, 0, default_tube);
40
41 b->r.id <<= 49;
42 assertf(job_pri_less(a, b), "should be less");
43 }
44
45
46 void
47 cttestjob_large_pris()
48 {
49 job a, b;
50
51 TUBE_ASSIGN(default_tube, make_tube("default"));
52 a = make_job(1, 0, 1, 0, default_tube);
53 b = make_job(-5, 0, 1, 0, default_tube);
54
55 assertf(job_pri_less(a, b), "should be less");
56
57 a = make_job(-5, 0, 1, 0, default_tube);
58 b = make_job(1, 0, 1, 0, default_tube);
59
60 assertf(!job_pri_less(a, b), "should not be less");
61 }
62
63 void
64 cttestjob_hash_free()
65 {
66 job j;
67 uint64 jid = 83;
68
69 TUBE_ASSIGN(default_tube, make_tube("default"));
70 j = make_job_with_id(0, 0, 1, 0, default_tube, jid);
71 job_free(j);
72
73 assertf(!job_find(jid), "job should be missing");
74 }
75
76 void
77 cttestjob_hash_free_next()
78 {
79 job a, b;
80 uint64 aid = 97, bid = 12386;
81
82 TUBE_ASSIGN(default_tube, make_tube("default"));
83 b = make_job_with_id(0, 0, 1, 0, default_tube, bid);
84 a = make_job_with_id(0, 0, 1, 0, default_tube, aid);
85
86 assertf(a->ht_next == b, "b should be chained to a");
87
88 job_free(b);
89
90 assertf(a->ht_next == NULL, "job should be missing");
91 }
92
93 void
94 cttestjob_all_jobs_used()
95 {
96 job j, x;
97
98 TUBE_ASSIGN(default_tube, make_tube("default"));
99 j = make_job(0, 0, 1, 0, default_tube);
100 assertf(get_all_jobs_used() == 1, "should match");
101
102 x = allocate_job(10);
103 assertf(get_all_jobs_used() == 1, "should match");
104
105 job_free(x);
106 assertf(get_all_jobs_used() == 1, "should match");
107
108 job_free(j);
109 assertf(get_all_jobs_used() == 0, "should match");
110 }
111
112 void
113 cttestjob_100_000_jobs()
114 {
115 int i;
116
117 TUBE_ASSIGN(default_tube, make_tube("default"));
118 for (i = 0; i < 100000; i++) {
119 make_job(0, 0, 1, 0, default_tube);
120 }
121 assertf(get_all_jobs_used() == 100000, "should match");
122
123 for (i = 1; i <= 100000; i++) {
124 job_free(job_find(i));
125 }
126 fprintf(stderr, "get_all_jobs_used() => %zu\n", get_all_jobs_used());
127 assertf(get_all_jobs_used() == 0, "should match");
128 }
+58
-91
job.c less more
0 /* job.c - a job in the queue */
1
2 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
0 #include <stdint.h>
181 #include <stdlib.h>
192 #include <string.h>
20
21 #include "tube.h"
22 #include "job.h"
23 #include "primes.h"
24 #include "util.h"
25
26 static uint64_t next_id = 1;
3 #include "dat.h"
4
5 static uint64 next_id = 1;
276
287 static int cur_prime = 0;
298
30 static job *all_jobs = NULL;
9 static job all_jobs_init[12289] = {0};
10 static job *all_jobs = all_jobs_init;
3111 static size_t all_jobs_cap = 12289; /* == primes[0] */
3212 static size_t all_jobs_used = 0;
3313
3616 static void rehash();
3717
3818 static int
39 _get_job_hash_index(uint64_t job_id)
19 _get_job_hash_index(uint64 job_id)
4020 {
4121 return job_id % all_jobs_cap;
4222 }
4626 {
4727 int index = 0;
4828
49 index = _get_job_hash_index(j->id);
29 index = _get_job_hash_index(j->r.id);
5030
5131 j->ht_next = all_jobs[index];
5232 all_jobs[index] = j;
8666 store_job(j);
8767 }
8868 }
89 free(old);
90 }
91
92 job
93 job_find(uint64_t job_id)
69 if (old != all_jobs_init) {
70 free(old);
71 }
72 }
73
74 job
75 job_find(uint64 job_id)
9476 {
9577 job jh = NULL;
9678 int index = _get_job_hash_index(job_id);
9779
98 for (jh = all_jobs[index]; jh && jh->id != job_id; jh = jh->ht_next);
80 for (jh = all_jobs[index]; jh && jh->r.id != job_id; jh = jh->ht_next);
9981
10082 return jh;
10183 }
10890 j = malloc(sizeof(struct job) + body_size);
10991 if (!j) return twarnx("OOM"), (job) 0;
11092
111 j->id = 0;
112 j->state = JOB_STATE_INVALID;
113 j->created_at = now_usec();
114 j->reserve_ct = j->timeout_ct = j->release_ct = j->bury_ct = j->kick_ct = 0;
115 j->body_size = body_size;
93 memset(j, 0, sizeof(struct job));
94 j->r.created_at = nanoseconds();
95 j->r.body_size = body_size;
11696 j->next = j->prev = j; /* not in a linked list */
117 j->ht_next = NULL;
118 j->tube = NULL;
119 j->binlog = NULL;
120 j->heap_index = 0;
121 j->reserved_binlog_space = 0;
122
12397 return j;
12498 }
12599
126100 job
127 make_job_with_id(unsigned int pri, usec delay, usec ttr,
128 int body_size, tube tube, uint64_t id)
101 make_job_with_id(uint pri, int64 delay, int64 ttr,
102 int body_size, tube tube, uint64 id)
129103 {
130104 job j;
131105
133107 if (!j) return twarnx("OOM"), (job) 0;
134108
135109 if (id) {
136 j->id = id;
110 j->r.id = id;
137111 if (id >= next_id) next_id = id + 1;
138112 } else {
139 j->id = next_id++;
140 }
141 j->pri = pri;
142 j->delay = delay;
143 j->ttr = ttr;
113 j->r.id = next_id++;
114 }
115 j->r.pri = pri;
116 j->r.delay = delay;
117 j->r.ttr = ttr;
144118
145119 store_job(j);
146120
154128 {
155129 job *slot;
156130
157 slot = &all_jobs[_get_job_hash_index(j->id)];
131 slot = &all_jobs[_get_job_hash_index(j->r.id)];
158132 while (*slot && *slot != j) slot = &(*slot)->ht_next;
159133 if (*slot) {
160134 *slot = (*slot)->ht_next;
167141 {
168142 if (j) {
169143 TUBE_ASSIGN(j->tube, NULL);
170 if (j->state != JOB_STATE_COPY) job_hash_free(j);
144 if (j->r.state != Copy) job_hash_free(j);
171145 }
172146
173147 free(j);
174148 }
175149
176 /* We can't substrct any of these values because there are too many bits */
150 void
151 job_setheappos(void *j, int pos)
152 {
153 ((job)j)->heap_index = pos;
154 }
155
177156 int
178 job_pri_cmp(job a, job b)
179 {
180 if (a->pri > b->pri) return 1;
181 if (a->pri < b->pri) return -1;
182 if (a->id > b->id) return 1;
183 if (a->id < b->id) return -1;
184 return 0;
185 }
186
187 /* We can't substrct any of these values because there are too many bits */
157 job_pri_less(void *ax, void *bx)
158 {
159 job a = ax, b = bx;
160 if (a->r.pri < b->r.pri) return 1;
161 if (a->r.pri > b->r.pri) return 0;
162 return a->r.id < b->r.id;
163 }
164
188165 int
189 job_delay_cmp(job a, job b)
190 {
191 if (a->deadline_at > b->deadline_at) return 1;
192 if (a->deadline_at < b->deadline_at) return -1;
193 if (a->id > b->id) return 1;
194 if (a->id < b->id) return -1;
195 return 0;
166 job_delay_less(void *ax, void *bx)
167 {
168 job a = ax, b = bx;
169 if (a->r.deadline_at < b->r.deadline_at) return 1;
170 if (a->r.deadline_at > b->r.deadline_at) return 0;
171 return a->r.id < b->r.id;
196172 }
197173
198174 job
202178
203179 if (!j) return NULL;
204180
205 n = malloc(sizeof(struct job) + j->body_size);
181 n = malloc(sizeof(struct job) + j->r.body_size);
206182 if (!n) return twarnx("OOM"), (job) 0;
207183
208 memcpy(n, j, sizeof(struct job) + j->body_size);
184 memcpy(n, j, sizeof(struct job) + j->r.body_size);
209185 n->next = n->prev = n; /* not in a linked list */
210186
211 n->binlog = NULL; /* copies do not have refcnt on the binlog */
187 n->file = NULL; /* copies do not have refcnt on the wal */
212188
213189 n->tube = 0; /* Don't use memcpy for the tube, which we must refcount. */
214190 TUBE_ASSIGN(n->tube, j->tube);
215191
216192 /* Mark this job as a copy so it can be appropriately freed later on */
217 n->state = JOB_STATE_COPY;
193 n->r.state = Copy;
218194
219195 return n;
220196 }
222198 const char *
223199 job_state(job j)
224200 {
225 if (j->state == JOB_STATE_READY) return "ready";
226 if (j->state == JOB_STATE_RESERVED) return "reserved";
227 if (j->state == JOB_STATE_BURIED) return "buried";
228 if (j->state == JOB_STATE_DELAYED) return "delayed";
201 if (j->r.state == Ready) return "ready";
202 if (j->r.state == Reserved) return "reserved";
203 if (j->r.state == Buried) return "buried";
204 if (j->r.state == Delayed) return "delayed";
229205 return "invalid";
230206 }
231207
260236 head->prev = j;
261237 }
262238
263 uint64_t
239 uint64
264240 total_jobs()
265241 {
266242 return next_id - 1;
272248 {
273249 return all_jobs_used;
274250 }
275
276 void
277 job_init()
278 {
279 all_jobs = calloc(all_jobs_cap, sizeof(job));
280 if (!all_jobs) {
281 twarnx("Failed to allocate %d hash buckets", all_jobs_cap);
282 }
283 }
+0
-103
job.h less more
0 /* job.h - a job in the queue */
1
2 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef job_h
19 #define job_h
20
21 #include "config.h"
22
23 #if HAVE_STDINT_H
24 # include <stdint.h>
25 #endif /* else we get int types from config.h */
26
27 #include "util.h"
28
29 typedef struct job *job;
30 typedef int(*job_cmp_fn)(job, job);
31
32 #include "tube.h"
33
34 #define JOB_STATE_INVALID 0
35 #define JOB_STATE_READY 1
36 #define JOB_STATE_RESERVED 2
37 #define JOB_STATE_BURIED 3
38 #define JOB_STATE_DELAYED 4
39 #define JOB_STATE_COPY 5
40
41 /* If you modify this struct, you MUST increment binlog format version in
42 * binlog.c. */
43 struct job {
44
45 /* persistent fields; these get written to the binlog */
46 uint64_t id;
47 uint32_t pri;
48 usec delay;
49 usec ttr;
50 int32_t body_size;
51 usec created_at;
52 usec deadline_at;
53 uint32_t reserve_ct;
54 uint32_t timeout_ct;
55 uint32_t release_ct;
56 uint32_t bury_ct;
57 uint32_t kick_ct;
58 uint8_t state;
59
60 /* bookeeping fields; these are in-memory only */
61 char pad[6];
62 tube tube;
63 job prev, next; /* linked list of jobs */
64 job ht_next; /* Next job in a hash table list */
65 size_t heap_index; /* where is this job in its current heap */
66 void *binlog;
67 void *reserver;
68 size_t reserved_binlog_space;
69
70 /* variable-size job data; written separately to the binlog */
71 char body[];
72 };
73
74 #define make_job(pri,delay,ttr,body_size,tube) make_job_with_id(pri,delay,ttr,body_size,tube,0)
75
76 job allocate_job(int body_size);
77 job make_job_with_id(unsigned int pri, usec delay, usec ttr,
78 int body_size, tube tube, uint64_t id);
79 void job_free(job j);
80
81 /* Lookup a job by job ID */
82 job job_find(uint64_t job_id);
83
84 int job_pri_cmp(job a, job b);
85 int job_delay_cmp(job a, job b);
86
87 job job_copy(job j);
88
89 const char * job_state(job j);
90
91 int job_list_any_p(job head);
92 job job_remove(job j);
93 void job_insert(job head, job j);
94
95 uint64_t total_jobs();
96
97 /* for unit tests */
98 size_t get_all_jobs_used();
99
100 void job_init();
101
102 #endif /*job_h*/
+0
-62
m4/as-compiler-flag.m4 less more
0 dnl as-compiler-flag.m4 0.1.0
1
2 dnl autostars m4 macro for detection of compiler flags
3
4 dnl David Schleef <ds@schleef.org>
5
6 dnl $Id: as-compiler-flag.m4,v 1.1 2005/12/15 23:35:19 ds Exp $
7
8 dnl AS_COMPILER_FLAG(CFLAGS, ACTION-IF-ACCEPTED, [ACTION-IF-NOT-ACCEPTED])
9 dnl Tries to compile with the given CFLAGS.
10 dnl Runs ACTION-IF-ACCEPTED if the compiler can compile with the flags,
11 dnl and ACTION-IF-NOT-ACCEPTED otherwise.
12
13 AC_DEFUN([AS_COMPILER_FLAG],
14 [
15 AC_MSG_CHECKING([to see if compiler understands $1])
16
17 save_CFLAGS="$CFLAGS"
18 CFLAGS="$CFLAGS $1"
19
20 AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
21 CFLAGS="$save_CFLAGS"
22
23 if test "X$flag_ok" = Xyes ; then
24 m4_ifvaln([$2],[$2])
25 true
26 else
27 m4_ifvaln([$3],[$3])
28 true
29 fi
30 AC_MSG_RESULT([$flag_ok])
31 ])
32
33 dnl AS_COMPILER_FLAGS(VAR, FLAGS)
34 dnl Tries to compile with the given CFLAGS.
35
36 AC_DEFUN([AS_COMPILER_FLAGS],
37 [
38 list=$2
39 flags_supported=""
40 flags_unsupported=""
41 AC_MSG_CHECKING([for supported compiler flags])
42 for each in $list
43 do
44 save_CFLAGS="$CFLAGS"
45 CFLAGS="$CFLAGS $each"
46 AC_TRY_COMPILE([ ], [], [flag_ok=yes], [flag_ok=no])
47 CFLAGS="$save_CFLAGS"
48
49 if test "X$flag_ok" = Xyes ; then
50 flags_supported="$flags_supported $each"
51 else
52 flags_unsupported="$flags_unsupported $each"
53 fi
54 done
55 AC_MSG_RESULT([$flags_supported])
56 if test "X$flags_unsupported" != X ; then
57 AC_MSG_WARN([unsupported compiler flags: $flags_unsupported])
58 fi
59 $1="$$1 $flags_supported"
60 ])
61
0 #include <signal.h>
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <errno.h>
4 #include <sys/stat.h>
5 #include <unistd.h>
6 #include <pwd.h>
7 #include <fcntl.h>
8 #include "sd-daemon.h"
9 #include "dat.h"
10
11 static char *user = NULL;
12 static char *port = "11300";
13 static char *host_addr;
14
15 static void
16 su(const char *user) {
17 int r;
18 struct passwd *pwent;
19
20 errno = 0;
21 pwent = getpwnam(user);
22 if (errno) twarn("getpwnam(\"%s\")", user), exit(32);
23 if (!pwent) twarnx("getpwnam(\"%s\"): no such user", user), exit(33);
24
25 r = setgid(pwent->pw_gid);
26 if (r == -1) twarn("setgid(%d \"%s\")", pwent->pw_gid, user), exit(34);
27
28 r = setuid(pwent->pw_uid);
29 if (r == -1) twarn("setuid(%d \"%s\")", pwent->pw_uid, user), exit(34);
30 }
31
32
33 static void
34 set_sig_handlers()
35 {
36 int r;
37 struct sigaction sa;
38
39 sa.sa_handler = SIG_IGN;
40 sa.sa_flags = 0;
41 r = sigemptyset(&sa.sa_mask);
42 if (r == -1) twarn("sigemptyset()"), exit(111);
43
44 r = sigaction(SIGPIPE, &sa, 0);
45 if (r == -1) twarn("sigaction(SIGPIPE)"), exit(111);
46
47 sa.sa_handler = enter_drain_mode;
48 r = sigaction(SIGUSR1, &sa, 0);
49 if (r == -1) twarn("sigaction(SIGUSR1)"), exit(111);
50 }
51
52 static void
53 usage(char *msg, char *arg)
54 {
55 if (arg) warnx("%s: %s", msg, arg);
56 fprintf(stderr, "Use: %s [OPTIONS]\n"
57 "\n"
58 "Options:\n"
59 " -b DIR wal directory (must be absolute path if used with -d)\n"
60 " -f MS fsync at most once every MS milliseconds"
61 " (use -f 0 for \"always fsync\")\n"
62 " -F never fsync (default)\n"
63 " -l ADDR listen on address (default is 0.0.0.0)\n"
64 " -p PORT listen on port (default is 11300)\n"
65 " -u USER become user and group\n"
66 " -z BYTES set the maximum job size in bytes (default is %d)\n"
67 " -s BYTES set the size of each wal file (default is %d)\n"
68 " (will be rounded up to a multiple of 512 bytes)\n"
69 " -c compact the binlog (default)\n"
70 " -n do not compact the binlog\n"
71 " -v show version information\n"
72 " -V increase verbosity\n"
73 " -h show this help\n",
74 progname, JOB_DATA_SIZE_LIMIT_DEFAULT, Filesizedef);
75 exit(arg ? 5 : 0);
76 }
77
78 static size_t
79 parse_size_t(char *str)
80 {
81 char r, x;
82 size_t size;
83
84 r = sscanf(str, "%zu%c", &size, &x);
85 if (1 != r) usage("invalid size", str);
86 return size;
87 }
88
89 static char *
90 require_arg(char *opt, char *arg)
91 {
92 if (!arg) usage("option requires an argument", opt);
93 return arg;
94 }
95
96 static void
97 warn_systemd_ignored_option(char *opt, char *arg)
98 {
99 if (sd_listen_fds(0) > 0) {
100 warnx("inherited listen fd; ignoring option: %s %s", opt, arg);
101 }
102 }
103
104 static void
105 opts(int argc, char **argv, Wal *w)
106 {
107 int i;
108 int64 ms;
109
110 for (i = 1; i < argc; ++i) {
111 if (argv[i][0] != '-') usage("unknown option", argv[i]);
112 if (argv[i][1] == 0 || argv[i][2] != 0) usage("unknown option",argv[i]);
113 switch (argv[i][1]) {
114 case 'p':
115 port = require_arg("-p", argv[++i]);
116 warn_systemd_ignored_option("-p", argv[i]);
117 break;
118 case 'l':
119 host_addr = require_arg("-l", argv[++i]);
120 warn_systemd_ignored_option("-l", argv[i]);
121 break;
122 case 'z':
123 job_data_size_limit = parse_size_t(require_arg("-z",
124 argv[++i]));
125 break;
126 case 's':
127 w->filesz = parse_size_t(require_arg("-s", argv[++i]));
128 break;
129 case 'c':
130 w->nocomp = 0;
131 break;
132 case 'n':
133 w->nocomp = 1;
134 break;
135 case 'f':
136 ms = (int64)parse_size_t(require_arg("-f", argv[++i]));
137 w->syncrate = ms * 1000000;
138 w->wantsync = 1;
139 break;
140 case 'F':
141 w->wantsync = 0;
142 break;
143 case 'u':
144 user = require_arg("-u", argv[++i]);
145 break;
146 case 'b':
147 w->dir = require_arg("-b", argv[++i]);
148 w->use = 1;
149 break;
150 case 'h':
151 usage(NULL, NULL);
152 case 'v':
153 printf("beanstalkd %s\n", version);
154 exit(0);
155 case 'V':
156 verbose++;
157 break;
158 default:
159 usage("unknown option", argv[i]);
160 }
161 }
162 }
163
164 int
165 main(int argc, char **argv)
166 {
167 int r;
168 Srv s = {};
169 s.wal.filesz = Filesizedef;
170 struct job list = {};
171
172 progname = argv[0];
173 opts(argc, argv, &s.wal);
174
175 if (verbose) {
176 printf("pid %d\n", getpid());
177 }
178
179 r = make_server_socket(host_addr, port);
180 if (r == -1) twarnx("make_server_socket()"), exit(111);
181 s.sock.fd = r;
182
183 prot_init();
184
185 if (user) su(user);
186 set_sig_handlers();
187
188 if (s.wal.use) {
189 // We want to make sure that only one beanstalkd tries
190 // to use the wal directory at a time. So acquire a lock
191 // now and never release it.
192 if (!waldirlock(&s.wal)) {
193 twarnx("failed to lock wal dir %s", s.wal.dir);
194 exit(10);
195 }
196
197 list.prev = list.next = &list;
198 walinit(&s.wal, &list);
199 prot_replay(&s, &list);
200 }
201
202 srv(&s);
203 return 0;
204 }
+0
-376
missing less more
0 #! /bin/sh
1 # Common stub for a few missing GNU programs while installing.
2
3 scriptversion=2009-04-28.21; # UTC
4
5 # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
6 # 2008, 2009 Free Software Foundation, Inc.
7 # Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
8
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
12 # any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21
22 # As a special exception to the GNU General Public License, if you
23 # distribute this file as part of a program that contains a
24 # configuration script generated by Autoconf, you may include it under
25 # the same distribution terms that you use for the rest of that program.
26
27 if test $# -eq 0; then
28 echo 1>&2 "Try \`$0 --help' for more information"
29 exit 1
30 fi
31
32 run=:
33 sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
34 sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
35
36 # In the cases where this matters, `missing' is being run in the
37 # srcdir already.
38 if test -f configure.ac; then
39 configure_ac=configure.ac
40 else
41 configure_ac=configure.in
42 fi
43
44 msg="missing on your system"
45
46 case $1 in
47 --run)
48 # Try to run requested program, and just exit if it succeeds.
49 run=
50 shift
51 "$@" && exit 0
52 # Exit code 63 means version mismatch. This often happens
53 # when the user try to use an ancient version of a tool on
54 # a file that requires a minimum version. In this case we
55 # we should proceed has if the program had been absent, or
56 # if --run hadn't been passed.
57 if test $? = 63; then
58 run=:
59 msg="probably too old"
60 fi
61 ;;
62
63 -h|--h|--he|--hel|--help)
64 echo "\
65 $0 [OPTION]... PROGRAM [ARGUMENT]...
66
67 Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
68 error status if there is no known handling for PROGRAM.
69
70 Options:
71 -h, --help display this help and exit
72 -v, --version output version information and exit
73 --run try to run the given command, and emulate it if it fails
74
75 Supported PROGRAM values:
76 aclocal touch file \`aclocal.m4'
77 autoconf touch file \`configure'
78 autoheader touch file \`config.h.in'
79 autom4te touch the output file, or create a stub one
80 automake touch all \`Makefile.in' files
81 bison create \`y.tab.[ch]', if possible, from existing .[ch]
82 flex create \`lex.yy.c', if possible, from existing .c
83 help2man touch the output file
84 lex create \`lex.yy.c', if possible, from existing .c
85 makeinfo touch the output file
86 tar try tar, gnutar, gtar, then tar without non-portable flags
87 yacc create \`y.tab.[ch]', if possible, from existing .[ch]
88
89 Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
90 \`g' are ignored when checking the name.
91
92 Send bug reports to <bug-automake@gnu.org>."
93 exit $?
94 ;;
95
96 -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
97 echo "missing $scriptversion (GNU Automake)"
98 exit $?
99 ;;
100
101 -*)
102 echo 1>&2 "$0: Unknown \`$1' option"
103 echo 1>&2 "Try \`$0 --help' for more information"
104 exit 1
105 ;;
106
107 esac
108
109 # normalize program name to check for.
110 program=`echo "$1" | sed '
111 s/^gnu-//; t
112 s/^gnu//; t
113 s/^g//; t'`
114
115 # Now exit if we have it, but it failed. Also exit now if we
116 # don't have it and --version was passed (most likely to detect
117 # the program). This is about non-GNU programs, so use $1 not
118 # $program.
119 case $1 in
120 lex*|yacc*)
121 # Not GNU programs, they don't have --version.
122 ;;
123
124 tar*)
125 if test -n "$run"; then
126 echo 1>&2 "ERROR: \`tar' requires --run"
127 exit 1
128 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
129 exit 1
130 fi
131 ;;
132
133 *)
134 if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
135 # We have it, but it failed.
136 exit 1
137 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
138 # Could not run --version or --help. This is probably someone
139 # running `$TOOL --version' or `$TOOL --help' to check whether
140 # $TOOL exists and not knowing $TOOL uses missing.
141 exit 1
142 fi
143 ;;
144 esac
145
146 # If it does not exist, or fails to run (possibly an outdated version),
147 # try to emulate it.
148 case $program in
149 aclocal*)
150 echo 1>&2 "\
151 WARNING: \`$1' is $msg. You should only need it if
152 you modified \`acinclude.m4' or \`${configure_ac}'. You might want
153 to install the \`Automake' and \`Perl' packages. Grab them from
154 any GNU archive site."
155 touch aclocal.m4
156 ;;
157
158 autoconf*)
159 echo 1>&2 "\
160 WARNING: \`$1' is $msg. You should only need it if
161 you modified \`${configure_ac}'. You might want to install the
162 \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
163 archive site."
164 touch configure
165 ;;
166
167 autoheader*)
168 echo 1>&2 "\
169 WARNING: \`$1' is $msg. You should only need it if
170 you modified \`acconfig.h' or \`${configure_ac}'. You might want
171 to install the \`Autoconf' and \`GNU m4' packages. Grab them
172 from any GNU archive site."
173 files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
174 test -z "$files" && files="config.h"
175 touch_files=
176 for f in $files; do
177 case $f in
178 *:*) touch_files="$touch_files "`echo "$f" |
179 sed -e 's/^[^:]*://' -e 's/:.*//'`;;
180 *) touch_files="$touch_files $f.in";;
181 esac
182 done
183 touch $touch_files
184 ;;
185
186 automake*)
187 echo 1>&2 "\
188 WARNING: \`$1' is $msg. You should only need it if
189 you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
190 You might want to install the \`Automake' and \`Perl' packages.
191 Grab them from any GNU archive site."
192 find . -type f -name Makefile.am -print |
193 sed 's/\.am$/.in/' |
194 while read f; do touch "$f"; done
195 ;;
196
197 autom4te*)
198 echo 1>&2 "\
199 WARNING: \`$1' is needed, but is $msg.
200 You might have modified some files without having the
201 proper tools for further handling them.
202 You can get \`$1' as part of \`Autoconf' from any GNU
203 archive site."
204
205 file=`echo "$*" | sed -n "$sed_output"`
206 test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
207 if test -f "$file"; then
208 touch $file
209 else
210 test -z "$file" || exec >$file
211 echo "#! /bin/sh"
212 echo "# Created by GNU Automake missing as a replacement of"
213 echo "# $ $@"
214 echo "exit 0"
215 chmod +x $file
216 exit 1
217 fi
218 ;;
219
220 bison*|yacc*)
221 echo 1>&2 "\
222 WARNING: \`$1' $msg. You should only need it if
223 you modified a \`.y' file. You may need the \`Bison' package
224 in order for those modifications to take effect. You can get
225 \`Bison' from any GNU archive site."
226 rm -f y.tab.c y.tab.h
227 if test $# -ne 1; then
228 eval LASTARG="\${$#}"
229 case $LASTARG in
230 *.y)
231 SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
232 if test -f "$SRCFILE"; then
233 cp "$SRCFILE" y.tab.c
234 fi
235 SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
236 if test -f "$SRCFILE"; then
237 cp "$SRCFILE" y.tab.h
238 fi
239 ;;
240 esac
241 fi
242 if test ! -f y.tab.h; then
243 echo >y.tab.h
244 fi
245 if test ! -f y.tab.c; then
246 echo 'main() { return 0; }' >y.tab.c
247 fi
248 ;;
249
250 lex*|flex*)
251 echo 1>&2 "\
252 WARNING: \`$1' is $msg. You should only need it if
253 you modified a \`.l' file. You may need the \`Flex' package
254 in order for those modifications to take effect. You can get
255 \`Flex' from any GNU archive site."
256 rm -f lex.yy.c
257 if test $# -ne 1; then
258 eval LASTARG="\${$#}"
259 case $LASTARG in
260 *.l)
261 SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
262 if test -f "$SRCFILE"; then
263 cp "$SRCFILE" lex.yy.c
264 fi
265 ;;
266 esac
267 fi
268 if test ! -f lex.yy.c; then
269 echo 'main() { return 0; }' >lex.yy.c
270 fi
271 ;;
272
273 help2man*)
274 echo 1>&2 "\
275 WARNING: \`$1' is $msg. You should only need it if
276 you modified a dependency of a manual page. You may need the
277 \`Help2man' package in order for those modifications to take
278 effect. You can get \`Help2man' from any GNU archive site."
279
280 file=`echo "$*" | sed -n "$sed_output"`
281 test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
282 if test -f "$file"; then
283 touch $file
284 else
285 test -z "$file" || exec >$file
286 echo ".ab help2man is required to generate this page"
287 exit $?
288 fi
289 ;;
290
291 makeinfo*)
292 echo 1>&2 "\
293 WARNING: \`$1' is $msg. You should only need it if
294 you modified a \`.texi' or \`.texinfo' file, or any other file
295 indirectly affecting the aspect of the manual. The spurious
296 call might also be the consequence of using a buggy \`make' (AIX,
297 DU, IRIX). You might want to install the \`Texinfo' package or
298 the \`GNU make' package. Grab either from any GNU archive site."
299 # The file to touch is that specified with -o ...
300 file=`echo "$*" | sed -n "$sed_output"`
301 test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
302 if test -z "$file"; then
303 # ... or it is the one specified with @setfilename ...
304 infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
305 file=`sed -n '
306 /^@setfilename/{
307 s/.* \([^ ]*\) *$/\1/
308 p
309 q
310 }' $infile`
311 # ... or it is derived from the source name (dir/f.texi becomes f.info)
312 test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
313 fi
314 # If the file does not exist, the user really needs makeinfo;
315 # let's fail without touching anything.
316 test -f $file || exit 1
317 touch $file
318 ;;
319
320 tar*)
321 shift
322
323 # We have already tried tar in the generic part.
324 # Look for gnutar/gtar before invocation to avoid ugly error
325 # messages.
326 if (gnutar --version > /dev/null 2>&1); then
327 gnutar "$@" && exit 0
328 fi
329 if (gtar --version > /dev/null 2>&1); then
330 gtar "$@" && exit 0
331 fi
332 firstarg="$1"
333 if shift; then
334 case $firstarg in
335 *o*)
336 firstarg=`echo "$firstarg" | sed s/o//`
337 tar "$firstarg" "$@" && exit 0
338 ;;
339 esac
340 case $firstarg in
341 *h*)
342 firstarg=`echo "$firstarg" | sed s/h//`
343 tar "$firstarg" "$@" && exit 0
344 ;;
345 esac
346 fi
347
348 echo 1>&2 "\
349 WARNING: I can't seem to be able to run \`tar' with the given arguments.
350 You may want to install GNU tar or Free paxutils, or check the
351 command line arguments."
352 exit 1
353 ;;
354
355 *)
356 echo 1>&2 "\
357 WARNING: \`$1' is needed, and is $msg.
358 You might have modified some files without having the
359 proper tools for further handling them. Check the \`README' file,
360 it often tells you about the needed prerequisites for installing
361 this package. You may also peek at any GNU archive site, in case
362 some other package would contain this missing \`$1' program."
363 exit 1
364 ;;
365 esac
366
367 exit 0
368
369 # Local variables:
370 # eval: (add-hook 'write-file-hooks 'time-stamp)
371 # time-stamp-start: "scriptversion="
372 # time-stamp-format: "%:y-%02m-%02d.%02H"
373 # time-stamp-time-zone: "UTC"
374 # time-stamp-end: "; # UTC"
375 # End:
0 all: $(TARG)
1 .PHONY: all
2
3 $(TARG): $(OFILES) $(MOFILE)
4 $(LINK.o) -o $@ $^ $(LDLIBS)
5
6 install: $(BINDIR) $(BINDIR)/$(TARG)
7 .PHONY: install
8
9 $(BINDIR):
10 $(INSTALL) -d $@
11
12 $(BINDIR)/%: %
13 $(INSTALL) $< $@
14
15 CLEANFILES:=$(CLEANFILES) $(TARG)
16
17 $(OFILES) $(MOFILE): $(HFILES)
18
19 clean:
20 rm -f *.o $(CLEANFILES)
21 .PHONY: clean
0 PREFIX=/usr/local
1 BINDIR=$(PREFIX)/bin
2 CFLAGS=-Wall -Werror
3 LDFLAGS=
4 OS=$(shell uname -s | tr A-Z a-z)
5 INSTALL=install
0 check-ct: ct/_ctcheck
1 ct/_ctcheck
2 .PHONY: check-ct
3
4 check-shell: $(TARG)
5 ./check.sh sh-tests/*.sh
6 .PHONY: check-shell
7
8 check: check-ct check-shell
9 .PHONY: check
10
11 ct/_ctcheck: ct/_ctcheck.o ct/ct.o $(OFILES) $(TOFILES)
12
13 ct/_ctcheck.c: $(TOFILES) ct/gen
14 ct/gen $(TOFILES) >$@.part
15 mv $@.part $@
16
17 ct/ct.o ct/_ctcheck.o: ct/ct.h ct/internal.h
18
19 $(TOFILES): $(HFILES) ct/ct.h
20
21 CLEANFILES:=$(CLEANFILES) ct/_* ct/*.o
0 #!/bin/sh
1
2 printf 'const char version[] = "'
3 mk/vers.sh
4 printf '";\n'
0 printf "1.5"
0 /* ms.c - resizable multiset implementation */
1
2 /* Copyright (C) 2008 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
0 #include <stdint.h>
181 #include <string.h>
192 #include <stdlib.h>
20
21 #include "ms.h"
22 #include "util.h"
3 #include "dat.h"
234
245 void
256 ms_init(ms a, ms_event_fn oninsert, ms_event_fn onremove)
+0
-41
ms.h less more
0 /* ms.h - resizable multiset header */
1
2 /* Copyright (C) 2008 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef ms_h
19 #define ms_h
20
21 #include <string.h>
22
23 typedef struct ms *ms;
24
25 typedef void(*ms_event_fn)(ms a, void *item, size_t i);
26
27 struct ms {
28 size_t used, cap, last;
29 void **items;
30 ms_event_fn oninsert, onremove;
31 };
32
33 void ms_init(ms a, ms_event_fn oninsert, ms_event_fn onremove);
34 void ms_clear(ms a);
35 int ms_append(ms a, void *item);
36 int ms_remove(ms a, void *item);
37 int ms_contains(ms a, void *item);
38 void *ms_take(ms a);
39
40 #endif /*ms_h*/
+53
-84
net.c less more
0 /* net.c - stupid boilerplate shit that I shouldn't have to write */
1
2 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
0 #include <netdb.h>
181 #include <stdio.h>
2 #include <unistd.h>
3 #include <fcntl.h>
194 #include <string.h>
205 #include <errno.h>
21
22 #include "net.h"
23 #include "util.h"
24
25 static int listen_socket = -1;
26 static struct event listen_evq;
27 static evh accept_handler;
28 static usec main_deadline = 0;
29 static int brakes_are_on = 1, after_startup = 0;
6 #include <sys/socket.h>
7 #include <netinet/in.h>
8 #include <netinet/tcp.h>
9 #include "dat.h"
10 #include "sd-daemon.h"
3011
3112 int
3213 make_server_socket(char *host, char *port)
3314 {
34 int fd, flags, r;
15 int fd = -1, flags, r;
3516 struct linger linger = {0, 0};
3617 struct addrinfo *airoot, *ai, hints;
18
19 /* See if we got a listen fd from systemd. If so, all socket options etc
20 * are already set, so we check that the fd is a TCP listen socket and
21 * return. */
22 r = sd_listen_fds(1);
23 if (r < 0) {
24 return twarn("sd_listen_fds"), -1;
25 }
26 if (r > 0) {
27 if (r > 1) {
28 twarnx("inherited more than one listen socket;"
29 " ignoring all but the first");
30 r = 1;
31 }
32 fd = SD_LISTEN_FDS_START;
33 r = sd_is_socket_inet(fd, 0, SOCK_STREAM, 1, 0);
34 if (r < 0) {
35 errno = -r;
36 twarn("sd_is_socket_inet");
37 return -1;
38 }
39 if (!r) {
40 twarnx("inherited fd is not a TCP listen socket");
41 return -1;
42 }
43 return fd;
44 }
3745
3846 memset(&hints, 0, sizeof(hints));
3947 hints.ai_family = PF_UNSPEC;
7078 setsockopt(fd, SOL_SOCKET, SO_LINGER, &linger, sizeof linger);
7179 setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flags, sizeof flags);
7280
81 if (verbose) {
82 char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV], *h = host, *p = port;
83 r = getnameinfo(ai->ai_addr, ai->ai_addrlen,
84 hbuf, sizeof hbuf,
85 pbuf, sizeof pbuf,
86 NI_NUMERICHOST|NI_NUMERICSERV);
87 if (!r) {
88 h = hbuf;
89 p = pbuf;
90 }
91 if (ai->ai_family == AF_INET6) {
92 printf("bind %d [%s]:%s\n", fd, h, p);
93 } else {
94 printf("bind %d %s:%s\n", fd, h, p);
95 }
96 }
7397 r = bind(fd, ai->ai_addr, ai->ai_addrlen);
7498 if (r == -1) {
7599 twarn("bind()");
92116 if(ai == NULL)
93117 fd = -1;
94118
95 return listen_socket = fd;
119 return fd;
96120 }
97
98 void
99 brake()
100 {
101 int r;
102
103 if (brakes_are_on) return;
104 brakes_are_on = 1;
105 twarnx("too many connections; putting on the brakes");
106
107 r = event_del(&listen_evq);
108 if (r == -1) twarn("event_del()");
109
110 r = listen(listen_socket, 0);
111 if (r == -1) twarn("listen()");
112 }
113
114 void
115 unbrake(evh h)
116 {
117 int r;
118
119 if (!brakes_are_on) return;
120 brakes_are_on = 0;
121 if (after_startup) twarnx("releasing the brakes");
122 after_startup = 1;
123
124 accept_handler = h ? : accept_handler;
125 event_set(&listen_evq, listen_socket, EV_READ | EV_PERSIST,
126 accept_handler, &listen_evq);
127
128 set_main_timeout(main_deadline);
129
130 r = listen(listen_socket, 1024);
131 if (r == -1) twarn("listen()");
132 }
133
134 void
135 set_main_timeout(usec deadline_at)
136 {
137 int r;
138 struct timeval tv;
139 usec now = now_usec();
140
141 main_deadline = deadline_at;
142
143 /* If there is no deadline, we just wait for a long while.
144 * This works around a bug in libevent or kqueue on Mac OS X. */
145 if (!deadline_at) deadline_at = now + 100 * SECOND;
146
147 timeval_from_usec(&tv, (deadline_at > now) ? deadline_at - now : 1);
148
149 r = event_add(&listen_evq, &tv);
150 if (r == -1) twarn("event_add()");
151 }
+0
-38
net.h less more
0 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
1
2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation, either version 3 of the License, or
5 * (at your option) any later version.
6
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 */
15
16 #ifndef net_h
17 #define net_h
18
19 #include <sys/types.h>
20 #include <sys/socket.h>
21 #include <netinet/in.h>
22 #include <netinet/tcp.h>
23 #include <netdb.h>
24 #include <unistd.h>
25 #include <fcntl.h>
26
27 #include "event.h"
28 #include "conn.h"
29 #include "util.h"
30
31 int make_server_socket(char *host_addr, char *port);
32
33 void brake();
34 void unbrake(evh h);
35 void set_main_timeout(usec deadline_at);
36
37 #endif /*net_h*/
0 %define beanstalkd_user beanstalkd
1 %define beanstalkd_group %{beanstalkd_user}
2 %define beanstalkd_home %{_localstatedir}/lib/beanstalkd
3 %define beanstalkd_logdir %{_localstatedir}/log/beanstalkd
4
5 Name: beanstalkd
6 Version: @VERSION@
7 Release: 0%{?dist}
8 Summary: A simple, fast workqueue service
9
10 Group: System Environment/Daemons
11 License: GPLv3+
12 URL: http://xph.us/software/%{name}/
13 Source0: http://xph.us/dist/%{name}/rel/%{name}-%{version}.tar.gz
14
15 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
16
17 Requires(pre): %{_sbindir}/useradd
18 Requires(post): /sbin/chkconfig
19 Requires(preun): /sbin/chkconfig, /sbin/service
20 Requires(postun): /sbin/service
21
22
23 %description
24 Beanstalk is a simple, fast workqueue service. Its interface is generic, but
25 was originally designed for reducing the latency of page views in high-volume
26 web applications by running time-consuming tasks asynchronously.
27
28
29 %prep
30 %setup -q
31 if [ ! -e configure ]; then
32 sh buildconf.sh
33 fi
34
35 %build
36 %configure --disable-rpath --docdir=%{_defaultdocdir}/%{name}-%{version}
37 make %{?_smp_mflags}
38
39 %install
40 rm -rf $RPM_BUILD_ROOT
41 make install DESTDIR=$RPM_BUILD_ROOT
42 %{__install} -p -D -m 0644 doc/%{name}.1 %{buildroot}%{_mandir}/man1/%{name}.1
43 %{__install} -p -D -m 0755 scripts/%{name}.init %{buildroot}%{_initrddir}/%{name}
44 %{__install} -p -D -m 0644 scripts/%{name}.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/%{name}
45
46
47 %clean
48 rm -rf $RPM_BUILD_ROOT
49
50 %pre
51 %{_sbindir}/useradd -c "beanstalkd user" -s /bin/false -r -m -d %{beanstalkd_home} %{beanstalkd_user} 2>/dev/null || :
52
53 %post
54 /sbin/chkconfig --add %{name}
55
56 %preun
57 if [ $1 = 0 ]; then
58 /sbin/service %{name} stop >/dev/null 2>&1
59 /sbin/chkconfig --del %{name}
60 fi
61
62 %postun
63 if [ $1 -ge 1 ]; then
64 /sbin/service %{name} condrestart > /dev/null 2>&1 || :
65 fi
66
67 %files
68 %defattr(-,root,root,-)
69 %doc %{_defaultdocdir}/%{name}-%{version}/protocol.txt
70 %doc README COPYING doc/protocol.txt
71 %{_initrddir}/%{name}
72 %{_bindir}/%{name}
73 %{_mandir}/man1/%{name}.1.gz
74 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}
75
76
77 %changelog
78 * Thu Oct 1 2009 Keith Rarick <kr@xph.us> - 1.4-0
79 - Convert this file to an autoconf template
80 - Tweak the summary and description
81
82 * Sun Jan 4 2009 Ask Bjørn Hansen <ask@develooper.com> - 1.2-0
83 - 1.2-tobe
84 - Use man page and .init/sysconfig scripts from .tar.gz
85
86 * Sat Nov 22 2008 Jeremy Hinegardner <jeremy at hinegardner dot org> - 1.1-1
87 - initial spec creation
0 #include <stdint.h>
1 #include <sys/types.h>
2 #include <unistd.h>
3 #include <errno.h>
4 #include "dat.h"
5
6 static char buf0[512]; /* buffer of zeros */
7
8 /* Allocate disk space.
9 * Expects fd's offset to be 0; may also reset fd's offset to 0.
10 * Returns 0 on success, and a positive errno otherwise. */
11 int
12 falloc(int fd, int len)
13 {
14 int i, w;
15
16 for (i = 0; i < len; i += w) {
17 w = write(fd, buf0, sizeof buf0);
18 if (w == -1) return errno;
19 }
20
21 lseek(fd, 0, 0); /* do not care if this fails */
22
23 return 0;
24 }
0 #include "port-bsd.c"
0 #include "port-bsd.c"
0 #define _XOPEN_SOURCE 600
1 #include <stdint.h>
2 #include <fcntl.h>
3 #include "dat.h"
4
5 /* Allocate disk space.
6 * Expects fd's offset to be 0; may also reset fd's offset to 0.
7 * Returns 0 on success, and a positive errno otherwise. */
8 int
9 falloc(int fd, int len)
10 {
11 return posix_fallocate(fd, 0, len);
12 }
+0
-31
port.c less more
0 /* port.c - portability functions */
1
2 /* Copyright (C) 2009 Keith Rarick
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "config.h"
19
20 #include <unistd.h>
21
22 #include "port.h"
23
24 #ifndef HAVE_FDATASYNC
25 int
26 fdatasync(int fd)
27 {
28 return fsync(fd);
29 }
30 #endif
+0
-28
port.h less more
0 /* port.h - portability functions */
1
2 /* Copyright (C) 2009 Keith Rarick.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef port_h
19 #define port_h
20
21 #include "config.h"
22
23 #ifndef HAVE_FDATASYNC
24 int fdatasync(int fd);
25 #endif
26
27 #endif /*port_h*/
+0
-182
pq.c less more
0 /* pq.c - priority queue */
1
2 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <stdlib.h>
19 #include <stdio.h>
20 #include <string.h>
21
22 #include "tube.h" /* hack to make cpp happy */
23 #include "pq.h"
24
25 void
26 pq_init(pq q, job_cmp_fn cmp)
27 {
28 if (!q) return;
29
30 q->cap = 0;
31 q->used = 0;
32 q->cmp = cmp;
33 q->heap = NULL;
34
35 return;
36 }
37
38 void
39 pq_clear(pq q)
40 {
41 free(q->heap);
42 pq_init(q, q->cmp);
43 }
44
45 static void
46 pq_grow(pq q)
47 {
48 job *nheap;
49 unsigned int ncap = q->cap << 1 ? : 1;
50
51 nheap = malloc(ncap * sizeof(job));
52 if (!nheap) return;
53
54 if (q->heap) memcpy(nheap, q->heap, q->used * sizeof(job));
55 free(q->heap);
56 q->heap = nheap;
57 q->cap = ncap;
58 }
59
60 static void
61 swap(pq q, unsigned int a, unsigned int b)
62 {
63 job j;
64
65 j = q->heap[a];
66 q->heap[a] = q->heap[b];
67 q->heap[b] = j;
68
69 q->heap[a]->heap_index = a;
70 q->heap[b]->heap_index = b;
71 }
72
73 #define PARENT(i) (((i-1))>>1)
74 #define CHILD_LEFT(i) (((i)<<1)+1)
75 #define CHILD_RIGHT(i) (((i)<<1)+2)
76
77 static int
78 cmp(pq q, unsigned int a, unsigned int b)
79 {
80 return q->cmp(q->heap[a], q->heap[b]);
81 }
82
83 static void
84 bubble_up(pq q, unsigned int k)
85 {
86 int p;
87
88 if (k == 0) return;
89 p = PARENT(k);
90 if (cmp(q, p, k) <= 0) return;
91 swap(q, k, p);
92 bubble_up(q, p);
93 }
94
95 static void
96 bubble_down(pq q, unsigned int k)
97 {
98 int l, r, s;
99
100 l = CHILD_LEFT(k);
101 r = CHILD_RIGHT(k);
102
103 s = k;
104 if (l < q->used && cmp(q, l, k) < 0) s = l;
105 if (r < q->used && cmp(q, r, s) < 0) s = r;
106 if (s == k) return; /* already satisfies the heap property */
107
108 swap(q, k, s);
109 bubble_down(q, s);
110 }
111
112 /* assumes there is at least one item in the queue */
113 static void
114 delete_min(pq q)
115 {
116 q->heap[0] = q->heap[--q->used];
117 q->heap[0]->heap_index = 0;
118 if (q->used) bubble_down(q, 0);
119 }
120
121 int
122 pq_give(pq q, job j)
123 {
124 int k;
125
126 if (q->used >= q->cap) pq_grow(q);
127 if (q->used >= q->cap) return 0;
128
129 k = q->used++;
130 q->heap[k] = j;
131 j->heap_index = k;
132 bubble_up(q, k);
133
134 return 1;
135 }
136
137 job
138 pq_take(pq q)
139 {
140 job j;
141
142 if (q->used == 0) return NULL;
143
144 j = q->heap[0];
145 delete_min(q);
146 return j;
147 }
148
149 job
150 pq_peek(pq q)
151 {
152 if (q->used == 0) return NULL;
153 return q->heap[0];
154 }
155
156 job
157 pq_remove(pq q, job j)
158 {
159 uint64_t id;
160 unsigned int pri;
161
162 if (j->heap_index >= q->used) return NULL;
163 if (q->heap[j->heap_index] != j) return NULL;
164
165 id = j->id;
166 j->id = 0;
167 pri = j->pri;
168 j->pri = 0;
169
170 bubble_up(q, j->heap_index);
171
172 j->id = id;
173 j->pri = pri;
174
175 /* can't happen */
176 if (q->heap[0] != j) return NULL;
177
178 delete_min(q);
179
180 return j;
181 }
+0
-50
pq.h less more
0 /* pq.h - priority queue header */
1
2 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef q_h
19 #define q_h
20
21 typedef struct pq *pq;
22
23 #include "job.h"
24
25 struct pq {
26 unsigned int cap;
27 unsigned int used;
28 job_cmp_fn cmp;
29 job *heap;
30 };
31
32 /* initialize a priority queue */
33 void pq_init(pq q, job_cmp_fn cmp);
34
35 void pq_clear(pq q);
36
37 /* return 1 if the job was inserted, else 0 */
38 int pq_give(pq q, job j);
39
40 /* return a job if the queue contains jobs, else NULL */
41 job pq_take(pq q);
42
43 /* return a job if the queue contains jobs, else NULL */
44 job pq_peek(pq q);
45
46 /* remove and return j if the queue contains j, else return NULL */
47 job pq_remove(pq q, job j);
48
49 #endif /*q_h*/
0 /* primes.c - exponentially increasing primes */
1
2 /* Copyright (C) 2008 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
180 #include <stdlib.h>
19 #include "primes.h"
201
212 size_t primes[] = {
223 12289,
+0
-27
primes.h less more
0 /* primes.h - exponentially increasing primes */
1
2 /* Copyright (C) 2008 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <stdlib.h>
19
20 #if _LP64
21 #define NUM_PRIMES 48
22 #else
23 #define NUM_PRIMES 19
24 #endif
25
26 extern size_t primes[];
+417
-362
prot.c less more
0 /* prot.c - protocol implementation */
1
2 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include "config.h"
19
0 #include <stdint.h>
201 #include <stdlib.h>
212 #include <stdio.h>
223 #include <unistd.h>
4 #include <fcntl.h>
235 #include <string.h>
246 #include <errno.h>
257 #include <sys/resource.h>
268 #include <sys/uio.h>
27 #include <stdarg.h>
9 #include <sys/types.h>
10 #include <sys/socket.h>
11 #include <netinet/in.h>
2812 #include <ctype.h>
2913 #include <inttypes.h>
30
31 #include "stat.h"
32 #include "prot.h"
33 #include "pq.h"
34 #include "ms.h"
35 #include "job.h"
36 #include "tube.h"
37 #include "conn.h"
38 #include "util.h"
39 #include "net.h"
40 #include "binlog.h"
14 #include <stdarg.h>
15 #include "dat.h"
4116
4217 /* job body cannot be greater than this many bytes long */
4318 size_t job_data_size_limit = JOB_DATA_SIZE_LIMIT_DEFAULT;
10479 #define MSG_RELEASED "RELEASED\r\n"
10580 #define MSG_BURIED "BURIED\r\n"
10681 #define MSG_TOUCHED "TOUCHED\r\n"
107 #define MSG_BURIED_FMT "BURIED %llu\r\n"
108 #define MSG_INSERTED_FMT "INSERTED %llu\r\n"
82 #define MSG_BURIED_FMT "BURIED %"PRIu64"\r\n"
83 #define MSG_INSERTED_FMT "INSERTED %"PRIu64"\r\n"
10984 #define MSG_NOT_IGNORED "NOT_IGNORED\r\n"
11085
11186 #define MSG_NOTFOUND_LEN CONSTSTRLEN(MSG_NOTFOUND)
198173 "rusage-utime: %d.%06d\n" \
199174 "rusage-stime: %d.%06d\n" \
200175 "uptime: %u\n" \
201 "binlog-oldest-index: %s\n" \
202 "binlog-current-index: %s\n" \
203 "binlog-max-size: %zu\n" \
176 "binlog-oldest-index: %d\n" \
177 "binlog-current-index: %d\n" \
178 "binlog-records-migrated: %" PRId64 "\n" \
179 "binlog-records-written: %" PRId64 "\n" \
180 "binlog-max-size: %d\n" \
204181 "\r\n"
205182
206183 #define STATS_TUBE_FMT "---\n" \
214191 "current-using: %u\n" \
215192 "current-watching: %u\n" \
216193 "current-waiting: %u\n" \
194 "cmd-delete: %" PRIu64 "\n" \
217195 "cmd-pause-tube: %u\n" \
218196 "pause: %" PRIu64 "\n" \
219 "pause-time-left: %" PRIu64 "\n" \
197 "pause-time-left: %" PRId64 "\n" \
220198 "\r\n"
221199
222200 #define STATS_JOB_FMT "---\n" \
224202 "tube: %s\n" \
225203 "state: %s\n" \
226204 "pri: %u\n" \
227 "age: %" PRIu64 "\n" \
228 "delay: %" PRIu64 "\n" \
229 "ttr: %" PRIu64 "\n" \
230 "time-left: %" PRIu64 "\n" \
205 "age: %" PRId64 "\n" \
206 "delay: %" PRId64 "\n" \
207 "ttr: %" PRId64 "\n" \
208 "time-left: %" PRId64 "\n" \
209 "file: %d\n" \
231210 "reserves: %u\n" \
232211 "timeouts: %u\n" \
233212 "releases: %u\n" \
240219
241220 static char bucket[BUCKET_BUF_SIZE];
242221
243 static unsigned int ready_ct = 0;
222 static uint ready_ct = 0;
244223 static struct stats global_stat = {0, 0, 0, 0, 0};
245224
246225 static tube default_tube;
247226
248227 static int drain_mode = 0;
249 static usec started_at;
250 static uint64_t op_ct[TOTAL_OPS], timeout_ct = 0;
251
228 static int64 started_at;
229 static uint64 op_ct[TOTAL_OPS], timeout_ct = 0;
230
231 static struct conn dirty = {&dirty, &dirty};
252232
253233 /* Doubly-linked list of connections with at least one reserved job. */
254 static struct conn running = { &running, &running, 0 };
255
256 #ifdef DEBUG
234 static struct conn running = { &running, &running };
235
257236 static const char * op_names[] = {
258237 "<unknown>",
259238 CMD_PUT,
280259 CMD_QUIT,
281260 CMD_PAUSE_TUBE
282261 };
283 #endif
284262
285263 static job remove_buried_job(job j);
286264
293271 static void
294272 reply(conn c, const char *line, int len, int state)
295273 {
296 int r;
297
298274 if (!c) return;
299275
300 r = conn_update_evq(c, EV_WRITE | EV_PERSIST);
301 if (r == -1) return twarnx("conn_update_evq() failed"), conn_close(c);
302
276 connwant(c, 'w', &dirty);
303277 c->reply = line;
304278 c->reply_len = len;
305279 c->reply_sent = 0;
306280 c->state = state;
307 dprintf("sending reply: %.*s", len, line);
281 if (verbose >= 2) {
282 printf(">%d reply %.*s\n", c->sock.fd, len-2, line);
283 }
308284 }
309285
310286 #define reply_msg(c,m) reply((c),(m),CONSTSTRLEN(m),STATE_SENDWORD)
335311 c->out_job = j;
336312 c->out_job_sent = 0;
337313
338 return reply_line(c, STATE_SENDJOB, "%s %llu %u\r\n",
339 word, j->id, j->body_size - 2);
314 return reply_line(c, STATE_SENDJOB, "%s %"PRIu64" %u\r\n",
315 word, j->r.id, j->r.body_size - 2);
340316 }
341317
342318 conn
360336 static void
361337 reserve_job(conn c, job j)
362338 {
363 j->deadline_at = now_usec() + j->ttr;
339 j->r.deadline_at = nanoseconds() + j->r.ttr;
364340 global_stat.reserved_ct++; /* stats */
365341 j->tube->stat.reserved_ct++;
366 j->reserve_ct++;
367 conn_insert(&running, c);
368 j->state = JOB_STATE_RESERVED;
342 j->r.reserve_ct++;
343 j->r.state = Reserved;
369344 job_insert(&c->reserved_jobs, j);
370345 j->reserver = c;
371 if (c->soonest_job && j->deadline_at < c->soonest_job->deadline_at) {
346 if (c->soonest_job && j->r.deadline_at < c->soonest_job->r.deadline_at) {
372347 c->soonest_job = j;
373348 }
374349 return reply_job(c, j, MSG_RESERVED);
375350 }
376351
377352 static job
378 next_eligible_job(usec now)
353 next_eligible_job(int64 now)
379354 {
380355 tube t;
381356 size_t i;
382357 job j = NULL, candidate;
383358
384 dprintf("tubes.used = %zu\n", tubes.used);
385359 for (i = 0; i < tubes.used; i++) {
386360 t = tubes.items[i];
387 dprintf("for %s t->waiting.used=%zu t->ready.used=%d t->pause=%" PRIu64 "\n",
388 t->name, t->waiting.used, t->ready.used, t->pause);
389361 if (t->pause) {
390362 if (t->deadline_at > now) continue;
391363 t->pause = 0;
392364 }
393 if (t->waiting.used && t->ready.used) {
394 candidate = pq_peek(&t->ready);
395 if (!j || job_pri_cmp(candidate, j) < 0) j = candidate;
396 }
397 dprintf("i = %zu, tubes.used = %zu\n", i, tubes.used);
365 if (t->waiting.used && t->ready.len) {
366 candidate = t->ready.data[0];
367 if (!j || job_pri_less(candidate, j)) {
368 j = candidate;
369 }
370 }
398371 }
399372
400373 return j;
404377 process_queue()
405378 {
406379 job j;
407 usec now = now_usec();
408
409 dprintf("processing queue\n");
380 int64 now = nanoseconds();
381
410382 while ((j = next_eligible_job(now))) {
411 dprintf("got eligible job %llu in %s\n", j->id, j->tube->name);
412 j = pq_take(&j->tube->ready);
383 heapremove(&j->tube->ready, j->heap_index);
413384 ready_ct--;
414 if (j->pri < URGENT_THRESHOLD) {
385 if (j->r.pri < URGENT_THRESHOLD) {
415386 global_stat.urgent_ct--;
416387 j->tube->stat.urgent_ct--;
417388 }
428399
429400 for (i = 0; i < tubes.used; i++) {
430401 t = tubes.items[i];
431 nj = pq_peek(&t->delay);
432 if (!nj) continue;
433 if (!j || nj->deadline_at < j->deadline_at) j = nj;
402 if (t->delay.len == 0) {
403 continue;
404 }
405 nj = t->delay.data[0];
406 if (!j || nj->r.deadline_at < j->r.deadline_at) j = nj;
434407 }
435408
436409 return j;
437410 }
438411
439 static tube
440 pause_tube_peek()
441 {
442 int i;
443 tube t, nt = NULL;
444
445 for (i = 0; i < tubes.used; i++) {
446 t = tubes.items[i];
447 if (t->pause) {
448 if (!nt || t->deadline_at < nt->deadline_at) nt = t;
449 }
450 }
451
452 return nt;
453 }
454
455 static void
456 set_main_delay_timeout()
457 {
458 job j = delay_q_peek();
459 tube t = pause_tube_peek();
460 usec deadline_at = t ? t->deadline_at : 0;
461
462 if (j && (!deadline_at || j->deadline_at < deadline_at)) deadline_at = j->deadline_at;
463
464 dprintf("deadline_at=%" PRIu64 "\n", deadline_at);
465 set_main_timeout(deadline_at);
466 }
467
468412 static int
469 enqueue_job(job j, usec delay, char update_store)
413 enqueue_job(Srv *s, job j, int64 delay, char update_store)
470414 {
471415 int r;
472416
473417 j->reserver = NULL;
474418 if (delay) {
475 j->deadline_at = now_usec() + delay;
476 r = pq_give(&j->tube->delay, j);
419 j->r.deadline_at = nanoseconds() + delay;
420 r = heapinsert(&j->tube->delay, j);
477421 if (!r) return 0;
478 j->state = JOB_STATE_DELAYED;
479 set_main_delay_timeout();
422 j->r.state = Delayed;
480423 } else {
481 r = pq_give(&j->tube->ready, j);
424 r = heapinsert(&j->tube->ready, j);
482425 if (!r) return 0;
483 j->state = JOB_STATE_READY;
426 j->r.state = Ready;
484427 ready_ct++;
485 if (j->pri < URGENT_THRESHOLD) {
428 if (j->r.pri < URGENT_THRESHOLD) {
486429 global_stat.urgent_ct++;
487430 j->tube->stat.urgent_ct++;
488431 }
489432 }
490433
491434 if (update_store) {
492 r = binlog_write_job(j);
493 if (!r) return -1;
435 if (!walwrite(&s->wal, j)) {
436 return 0;
437 }
438 walmaint(&s->wal);
494439 }
495440
496441 process_queue();
498443 }
499444
500445 static int
501 bury_job(job j, char update_store)
502 {
503 size_t z;
446 bury_job(Srv *s, job j, char update_store)
447 {
448 int z;
504449
505450 if (update_store) {
506 z = binlog_reserve_space_update(j);
451 z = walresvupdate(&s->wal, j);
507452 if (!z) return 0;
508 j->reserved_binlog_space += z;
453 j->walresv += z;
509454 }
510455
511456 job_insert(&j->tube->buried, j);
512457 global_stat.buried_ct++;
513458 j->tube->stat.buried_ct++;
514 j->state = JOB_STATE_BURIED;
459 j->r.state = Buried;
515460 j->reserver = NULL;
516 j->bury_ct++;
517
518 if (update_store) return binlog_write_job(j);
461 j->r.bury_ct++;
462
463 if (update_store) {
464 if (!walwrite(&s->wal, j)) {
465 return 0;
466 }
467 walmaint(&s->wal);
468 }
519469
520470 return 1;
521471 }
528478
529479 while (job_list_any_p(&c->reserved_jobs)) {
530480 j = job_remove(c->reserved_jobs.next);
531 r = enqueue_job(j, 0, 0);
532 if (r < 1) bury_job(j, 0);
481 r = enqueue_job(c->srv, j, 0, 0);
482 if (r < 1) bury_job(c->srv, j, 0);
533483 global_stat.reserved_ct--;
534484 j->tube->stat.reserved_ct--;
535485 c->soonest_job = NULL;
541491 delay_q_take()
542492 {
543493 job j = delay_q_peek();
544 return j ? pq_take(&j->tube->delay) : NULL;
494 if (!j) {
495 return 0;
496 }
497 heapremove(&j->tube->delay, j->heap_index);
498 return j;
545499 }
546500
547501 static int
548 kick_buried_job(tube t)
502 kick_buried_job(Srv *s, tube t)
549503 {
550504 int r;
551505 job j;
552 size_t z;
506 int z;
553507
554508 if (!buried_job_p(t)) return 0;
555509 j = remove_buried_job(t->buried.next);
556510
557 z = binlog_reserve_space_update(j);
558 if (!z) return pq_give(&t->delay, j), 0; /* put it back */
559 j->reserved_binlog_space += z;
560
561 j->kick_ct++;
562 r = enqueue_job(j, 0, 1);
511 z = walresvupdate(&s->wal, j);
512 if (!z) return heapinsert(&t->delay, j), 0; /* put it back */
513 j->walresv += z;
514
515 j->r.kick_ct++;
516 r = enqueue_job(s, j, 0, 1);
563517 if (r == 1) return 1;
564518
565519 /* ready queue is full, so bury it */
566 bury_job(j, 0);
520 bury_job(s, j, 0);
567521 return 0;
568522 }
569523
570 static unsigned int
524 static uint
571525 get_delayed_job_ct()
572526 {
573527 tube t;
574528 size_t i;
575 unsigned int count = 0;
529 uint count = 0;
576530
577531 for (i = 0; i < tubes.used; i++) {
578532 t = tubes.items[i];
579 count += t->delay.used;
533 count += t->delay.len;
580534 }
581535 return count;
582536 }
583537
584538 static int
585 kick_delayed_job(tube t)
539 kick_delayed_job(Srv *s, tube t)
586540 {
587541 int r;
588542 job j;
589 size_t z;
590
591 j = pq_take(&t->delay);
592 if (!j) return 0;
593
594 z = binlog_reserve_space_update(j);
595 if (!z) return pq_give(&t->delay, j), 0; /* put it back */
596 j->reserved_binlog_space += z;
597
598 j->kick_ct++;
599 r = enqueue_job(j, 0, 1);
543 int z;
544
545 if (t->delay.len == 0) {
546 return 0;
547 }
548
549 j = heapremove(&t->delay, 0);
550
551 z = walresvupdate(&s->wal, j);
552 if (!z) return heapinsert(&t->delay, j), 0; /* put it back */
553 j->walresv += z;
554
555 j->r.kick_ct++;
556 r = enqueue_job(s, j, 0, 1);
600557 if (r == 1) return 1;
601558
602559 /* ready queue is full, so delay it again */
603 r = enqueue_job(j, j->delay, 0);
560 r = enqueue_job(s, j, j->r.delay, 0);
604561 if (r == 1) return 0;
605562
606563 /* last resort */
607 bury_job(j, 0);
564 bury_job(s, j, 0);
608565 return 0;
609566 }
610567
611568 /* return the number of jobs successfully kicked */
612 static unsigned int
613 kick_buried_jobs(tube t, unsigned int n)
614 {
615 unsigned int i;
616 for (i = 0; (i < n) && kick_buried_job(t); ++i);
569 static uint
570 kick_buried_jobs(Srv *s, tube t, uint n)
571 {
572 uint i;
573 for (i = 0; (i < n) && kick_buried_job(s, t); ++i);
617574 return i;
618575 }
619576
620577 /* return the number of jobs successfully kicked */
621 static unsigned int
622 kick_delayed_jobs(tube t, unsigned int n)
623 {
624 unsigned int i;
625 for (i = 0; (i < n) && kick_delayed_job(t); ++i);
578 static uint
579 kick_delayed_jobs(Srv *s, tube t, uint n)
580 {
581 uint i;
582 for (i = 0; (i < n) && kick_delayed_job(s, t); ++i);
626583 return i;
627584 }
628585
629 static unsigned int
630 kick_jobs(tube t, unsigned int n)
631 {
632 if (buried_job_p(t)) return kick_buried_jobs(t, n);
633 return kick_delayed_jobs(t, n);
586 static uint
587 kick_jobs(Srv *s, tube t, uint n)
588 {
589 if (buried_job_p(t)) return kick_buried_jobs(s, t, n);
590 return kick_delayed_jobs(s, t, n);
634591 }
635592
636593 static job
637594 remove_buried_job(job j)
638595 {
639 if (!j || j->state != JOB_STATE_BURIED) return NULL;
596 if (!j || j->r.state != Buried) return NULL;
640597 j = job_remove(j);
641598 if (j) {
642599 global_stat.buried_ct--;
646603 }
647604
648605 static job
606 remove_delayed_job(job j)
607 {
608 if (!j || j->r.state != Delayed) return NULL;
609 heapremove(&j->tube->delay, j->heap_index);
610
611 return j;
612 }
613
614 static job
649615 remove_ready_job(job j)
650616 {
651 if (!j || j->state != JOB_STATE_READY) return NULL;
652 j = pq_remove(&j->tube->ready, j);
653 if (j) {
654 ready_ct--;
655 if (j->pri < URGENT_THRESHOLD) {
656 global_stat.urgent_ct--;
657 j->tube->stat.urgent_ct--;
658 }
617 if (!j || j->r.state != Ready) return NULL;
618 heapremove(&j->tube->ready, j->heap_index);
619 ready_ct--;
620 if (j->r.pri < URGENT_THRESHOLD) {
621 global_stat.urgent_ct--;
622 j->tube->stat.urgent_ct--;
659623 }
660624 return j;
661625 }
678642 static job
679643 find_reserved_job_in_conn(conn c, job j)
680644 {
681 return (j && j->reserver == c && j->state == JOB_STATE_RESERVED) ? j : NULL;
645 return (j && j->reserver == c && j->r.state == Reserved) ? j : NULL;
682646 }
683647
684648 static job
686650 {
687651 j = find_reserved_job_in_conn(c, j);
688652 if (j) {
689 j->deadline_at = now_usec() + j->ttr;
653 j->r.deadline_at = nanoseconds() + j->r.ttr;
690654 c->soonest_job = NULL;
691655 }
692656 return j;
693657 }
694658
695659 static job
696 peek_job(uint64_t id)
660 peek_job(uint64 id)
697661 {
698662 return job_find(id);
699663 }
771735 {
772736 int extra_bytes, job_data_bytes = 0, cmd_bytes;
773737
774 if (!c->fd) return; /* the connection was closed */
738 if (!c->sock.fd) return; /* the connection was closed */
775739 if (!c->cmd_len) return; /* we don't have a complete command */
776740
777741 /* how many extra bytes did we read? */
779743
780744 /* how many bytes should we put into the job body? */
781745 if (c->in_job) {
782 job_data_bytes = min(extra_bytes, c->in_job->body_size);
746 job_data_bytes = min(extra_bytes, c->in_job->r.body_size);
783747 memcpy(c->in_job->body, c->cmd + c->cmd_len, job_data_bytes);
784748 c->in_job_read = job_data_bytes;
785749 } else if (c->in_job_read) {
825789 c->in_job_read = 0;
826790
827791 /* check if the trailer is present and correct */
828 if (memcmp(j->body + j->body_size - 2, "\r\n", 2)) {
792 if (memcmp(j->body + j->r.body_size - 2, "\r\n", 2)) {
829793 job_free(j);
830794 return reply_msg(c, MSG_EXPECTED_CRLF);
795 }
796
797 if (verbose >= 2) {
798 printf("<%d job %"PRIu64"\n", c->sock.fd, j->r.id);
831799 }
832800
833801 if (drain_mode) {
835803 return reply_serr(c, MSG_DRAINING);
836804 }
837805
838 if (j->reserved_binlog_space) return reply_serr(c, MSG_INTERNAL_ERROR);
839 j->reserved_binlog_space = binlog_reserve_space_put(j);
840 if (!j->reserved_binlog_space) return reply_serr(c, MSG_OUT_OF_MEMORY);
806 if (j->walresv) return reply_serr(c, MSG_INTERNAL_ERROR);
807 j->walresv = walresvput(&c->srv->wal, j);
808 if (!j->walresv) return reply_serr(c, MSG_OUT_OF_MEMORY);
841809
842810 /* we have a complete job, so let's stick it in the pqueue */
843 r = enqueue_job(j, j->delay, 1);
811 r = enqueue_job(c->srv, j, j->r.delay, 1);
844812 if (r < 0) return reply_serr(c, MSG_INTERNAL_ERROR);
845813
846814 op_ct[OP_PUT]++; /* stats */
847815 global_stat.total_jobs_ct++;
848816 j->tube->stat.total_jobs_ct++;
849817
850 if (r == 1) return reply_line(c, STATE_SENDWORD, MSG_INSERTED_FMT, j->id);
818 if (r == 1) return reply_line(c, STATE_SENDWORD, MSG_INSERTED_FMT, j->r.id);
851819
852820 /* out of memory trying to grow the queue, so it gets buried */
853 bury_job(j, 0);
854 reply_line(c, STATE_SENDWORD, MSG_BURIED_FMT, j->id);
855 }
856
857 static unsigned int
821 bury_job(c->srv, j, 0);
822 reply_line(c, STATE_SENDWORD, MSG_BURIED_FMT, j->r.id);
823 }
824
825 static uint
858826 uptime()
859827 {
860 return (now_usec() - started_at) / 1000000;
828 return (nanoseconds() - started_at) / 1000000000;
861829 }
862830
863831 static int
864832 fmt_stats(char *buf, size_t size, void *x)
865833 {
834 int whead = 0, wcur = 0;
835 Srv *srv;
866836 struct rusage ru = {{0, 0}, {0, 0}};
837
838 srv = x;
839
840 if (srv->wal.head) {
841 whead = srv->wal.head->seq;
842 }
843
844 if (srv->wal.cur) {
845 wcur = srv->wal.cur->seq;
846 }
847
867848 getrusage(RUSAGE_SELF, &ru); /* don't care if it fails */
868849 return snprintf(buf, size, STATS_FMT,
869850 global_stat.urgent_ct,
903884 global_stat.waiting_ct,
904885 count_tot_conns(),
905886 (long) getpid(),
906 VERSION,
887 version,
907888 (int) ru.ru_utime.tv_sec, (int) ru.ru_utime.tv_usec,
908889 (int) ru.ru_stime.tv_sec, (int) ru.ru_stime.tv_usec,
909890 uptime(),
910 binlog_oldest_index(),
911 binlog_current_index(),
912 binlog_size_limit);
891 whead,
892 wcur,
893 srv->wal.nmig,
894 srv->wal.nrec,
895 srv->wal.filesz);
913896
914897 }
915898
923906 * Return 0 on success, or nonzero on failure.
924907 * If a failure occurs, pri and end are not modified. */
925908 static int
926 read_pri(unsigned int *pri, const char *buf, char **end)
909 read_pri(uint *pri, const char *buf, char **end)
927910 {
928911 char *tend;
929 unsigned int tpri;
912 uint tpri;
930913
931914 errno = 0;
932915 while (buf[0] == ' ') buf++;
944927 /* Read a delay value from the given buffer and place it in delay.
945928 * The interface and behavior are analogous to read_pri(). */
946929 static int
947 read_delay(usec *delay, const char *buf, char **end)
930 read_delay(int64 *delay, const char *buf, char **end)
948931 {
949932 int r;
950 unsigned int delay_sec;
933 uint delay_sec;
951934
952935 r = read_pri(&delay_sec, buf, end);
953936 if (r) return r;
954 *delay = ((usec) delay_sec) * 1000000;
937 *delay = ((int64) delay_sec) * 1000000000;
955938 return 0;
956939 }
957940
958941 /* Read a timeout value from the given buffer and place it in ttr.
959942 * The interface and behavior are the same as in read_delay(). */
960943 static int
961 read_ttr(usec *ttr, const char *buf, char **end)
944 read_ttr(int64 *ttr, const char *buf, char **end)
962945 {
963946 return read_delay(ttr, buf, end);
964947 }
980963 static void
981964 wait_for_job(conn c, int timeout)
982965 {
983 int r;
984
985966 c->state = STATE_WAIT;
986967 enqueue_waiting_conn(c);
987968
988969 /* Set the pending timeout to the requested timeout amount */
989970 c->pending_timeout = timeout;
990971
991 /* this conn is waiting, but we want to know if they hang up */
992 r = conn_update_evq(c, EV_READ | EV_PERSIST);
993 if (r == -1) return twarnx("update events failed"), conn_close(c);
972 connwant(c, 'h', &dirty); // only care if they hang up
994973 }
995974
996975 typedef int(*fmt_fn)(char *, size_t, void *);
1007986 if (!c->out_job) return reply_serr(c, MSG_OUT_OF_MEMORY);
1008987
1009988 /* Mark this job as a copy so it can be appropriately freed later on */
1010 c->out_job->state = JOB_STATE_COPY;
989 c->out_job->r.state = Copy;
1011990
1012991 /* now actually format the stats data */
1013992 r = fmt(c->out_job->body, stats_len, data);
1014993 /* and set the actual body size */
1015 c->out_job->body_size = r;
994 c->out_job->r.body_size = r;
1016995 if (r > stats_len) return reply_serr(c, MSG_INTERNAL_ERROR);
1017996
1018997 c->out_job_sent = 0;
10371016 if (!c->out_job) return reply_serr(c, MSG_OUT_OF_MEMORY);
10381017
10391018 /* Mark this job as a copy so it can be appropriately freed later on */
1040 c->out_job->state = JOB_STATE_COPY;
1019 c->out_job->r.state = Copy;
10411020
10421021 /* now actually format the response */
10431022 buf = c->out_job->body;
10561035 static int
10571036 fmt_job_stats(char *buf, size_t size, job j)
10581037 {
1059 usec t;
1060 uint64_t time_left;
1061
1062 t = now_usec();
1063 if (j->state == JOB_STATE_RESERVED || j->state == JOB_STATE_DELAYED) {
1064 time_left = (j->deadline_at - t) / 1000000;
1038 int64 t;
1039 int64 time_left;
1040 int file = 0;
1041
1042 t = nanoseconds();
1043 if (j->r.state == Reserved || j->r.state == Delayed) {
1044 time_left = (j->r.deadline_at - t) / 1000000000;
10651045 } else {
10661046 time_left = 0;
10671047 }
1048 if (j->file) {
1049 file = j->file->seq;
1050 }
10681051 return snprintf(buf, size, STATS_JOB_FMT,
1069 j->id,
1052 j->r.id,
10701053 j->tube->name,
10711054 job_state(j),
1072 j->pri,
1073 (t - j->created_at) / 1000000,
1074 j->delay / 1000000,
1075 j->ttr / 1000000,
1055 j->r.pri,
1056 (t - j->r.created_at) / 1000000000,
1057 j->r.delay / 1000000000,
1058 j->r.ttr / 1000000000,
10761059 time_left,
1077 j->reserve_ct,
1078 j->timeout_ct,
1079 j->release_ct,
1080 j->bury_ct,
1081 j->kick_ct);
1060 file,
1061 j->r.reserve_ct,
1062 j->r.timeout_ct,
1063 j->r.release_ct,
1064 j->r.bury_ct,
1065 j->r.kick_ct);
10821066 }
10831067
10841068 static int
10851069 fmt_stats_tube(char *buf, size_t size, tube t)
10861070 {
1087 uint64_t time_left;
1071 uint64 time_left;
10881072
10891073 if (t->pause > 0) {
1090 time_left = (t->deadline_at - now_usec()) / 1000000;
1074 time_left = (t->deadline_at - nanoseconds()) / 1000000000;
10911075 } else {
10921076 time_left = 0;
10931077 }
10941078 return snprintf(buf, size, STATS_TUBE_FMT,
10951079 t->name,
10961080 t->stat.urgent_ct,
1097 t->ready.used,
1081 t->ready.len,
10981082 t->stat.reserved_ct,
1099 t->delay.used,
1083 t->delay.len,
11001084 t->stat.buried_ct,
11011085 t->stat.total_jobs_ct,
11021086 t->using_ct,
11031087 t->watching_ct,
11041088 t->stat.waiting_ct,
1089 t->stat.total_delete_ct,
11051090 t->stat.pause_ct,
1106 t->pause / 1000000,
1091 t->pause / 1000000000,
11071092 time_left);
11081093 }
11091094
11131098 job j = c->in_job;
11141099
11151100 /* do we have a complete job? */
1116 if (c->in_job_read == j->body_size) return enqueue_incoming_job(c);
1101 if (c->in_job_read == j->r.body_size) return enqueue_incoming_job(c);
11171102
11181103 /* otherwise we have incomplete data, so just keep waiting */
11191104 c->state = STATE_WANTDATA;
11581143 dispatch_cmd(conn c)
11591144 {
11601145 int r, i, timeout = -1;
1161 size_t z;
1162 unsigned int count;
1163 job j;
1164 unsigned char type;
1146 int z;
1147 uint count;
1148 job j = 0;
1149 byte type;
11651150 char *size_buf, *delay_buf, *ttr_buf, *pri_buf, *end_buf, *name;
1166 unsigned int pri, body_size;
1167 usec delay, ttr;
1168 uint64_t id;
1151 uint pri, body_size;
1152 int64 delay, ttr;
1153 uint64 id;
11691154 tube t = NULL;
11701155
11711156 /* NUL-terminate this string so we can use strtol and friends */
11771162 }
11781163
11791164 type = which_cmd(c);
1180 dprintf("got %s command: \"%s\"\n", op_names[(int) type], c->cmd);
1165 if (verbose >= 2) {
1166 printf("<%d command %s\n", c->sock.fd, op_names[type]);
1167 }
11811168
11821169 switch (type) {
11831170 case OP_PUT:
12041191
12051192 conn_set_producer(c);
12061193
1207 c->in_job = make_job(pri, delay, ttr ? : 1, body_size + 2, c->use);
1194 if (ttr < 1000000000) {
1195 ttr = 1000000000;
1196 }
1197
1198 c->in_job = make_job(pri, delay, ttr, body_size + 2, c->use);
12081199
12091200 /* OOM? */
12101201 if (!c->in_job) {
12261217 }
12271218 op_ct[type]++;
12281219
1229 j = job_copy(pq_peek(&c->use->ready));
1220 if (c->use->ready.len) {
1221 j = job_copy(c->use->ready.data[0]);
1222 }
12301223
12311224 if (!j) return reply(c, MSG_NOTFOUND, MSG_NOTFOUND_LEN, STATE_SENDWORD);
12321225
12391232 }
12401233 op_ct[type]++;
12411234
1242 j = job_copy(pq_peek(&c->use->delay));
1235 if (c->use->delay.len) {
1236 j = job_copy(c->use->delay.data[0]);
1237 }
12431238
12441239 if (!j) return reply(c, MSG_NOTFOUND, MSG_NOTFOUND_LEN, STATE_SENDWORD);
12451240
13031298 j = job_find(id);
13041299 j = remove_reserved_job(c, j) ? :
13051300 remove_ready_job(j) ? :
1306 remove_buried_job(j);
1301 remove_buried_job(j) ? :
1302 remove_delayed_job(j);
13071303
13081304 if (!j) return reply(c, MSG_NOTFOUND, MSG_NOTFOUND_LEN, STATE_SENDWORD);
13091305
1310 j->state = JOB_STATE_INVALID;
1311 r = binlog_write_job(j);
1306 j->tube->stat.total_delete_ct++;
1307
1308 j->r.state = Invalid;
1309 r = walwrite(&c->srv->wal, j);
1310 walmaint(&c->srv->wal);
13121311 job_free(j);
13131312
13141313 if (!r) return reply_serr(c, MSG_INTERNAL_ERROR);
13341333 /* We want to update the delay deadline on disk, so reserve space for
13351334 * that. */
13361335 if (delay) {
1337 z = binlog_reserve_space_update(j);
1336 z = walresvupdate(&c->srv->wal, j);
13381337 if (!z) return reply_serr(c, MSG_OUT_OF_MEMORY);
1339 j->reserved_binlog_space += z;
1340 }
1341
1342 j->pri = pri;
1343 j->delay = delay;
1344 j->release_ct++;
1345
1346 r = enqueue_job(j, delay, !!delay);
1338 j->walresv += z;
1339 }
1340
1341 j->r.pri = pri;
1342 j->r.delay = delay;
1343 j->r.release_ct++;
1344
1345 r = enqueue_job(c->srv, j, delay, !!delay);
13471346 if (r < 0) return reply_serr(c, MSG_INTERNAL_ERROR);
13481347 if (r == 1) {
13491348 return reply(c, MSG_RELEASED, MSG_RELEASED_LEN, STATE_SENDWORD);
13501349 }
13511350
13521351 /* out of memory trying to grow the queue, so it gets buried */
1353 bury_job(j, 0);
1352 bury_job(c->srv, j, 0);
13541353 reply(c, MSG_BURIED, MSG_BURIED_LEN, STATE_SENDWORD);
13551354 break;
13561355 case OP_BURY:
13661365
13671366 if (!j) return reply(c, MSG_NOTFOUND, MSG_NOTFOUND_LEN, STATE_SENDWORD);
13681367
1369 j->pri = pri;
1370 r = bury_job(j, 1);
1368 j->r.pri = pri;
1369 r = bury_job(c->srv, j, 1);
13711370 if (!r) return reply_serr(c, MSG_INTERNAL_ERROR);
13721371 reply(c, MSG_BURIED, MSG_BURIED_LEN, STATE_SENDWORD);
13731372 break;
13811380
13821381 op_ct[type]++;
13831382
1384 i = kick_jobs(c->use, count);
1383 i = kick_jobs(c->srv, c->use, count);
13851384
13861385 return reply_line(c, STATE_SENDWORD, "KICKED %u\r\n", i);
13871386 case OP_TOUCH:
14071406
14081407 op_ct[type]++;
14091408
1410 do_stats(c, fmt_stats, NULL);
1409 do_stats(c, fmt_stats, c->srv);
14111410 break;
14121411 case OP_JOBSTATS:
14131412 errno = 0;
15261525 t = tube_find(name);
15271526 if (!t) return reply_msg(c, MSG_NOTFOUND);
15281527
1529 t->deadline_at = now_usec() + delay;
1528 t->deadline_at = nanoseconds() + delay;
15301529 t->pause = delay;
15311530 t->stat.pause_ct++;
1532 set_main_delay_timeout();
15331531
15341532 reply_line(c, STATE_SENDWORD, "PAUSED\r\n");
15351533 break;
15471545 *
15481546 * If any of these happen, we must do the appropriate thing. */
15491547 static void
1550 h_conn_timeout(conn c)
1548 conn_timeout(conn c)
15511549 {
15521550 int r, should_timeout = 0;
15531551 job j;
15581556 /* Check if any reserved jobs have run out of time. We should do this
15591557 * whether or not the client is waiting for a new reservation. */
15601558 while ((j = soonest_job(c))) {
1561 if (j->deadline_at >= now_usec()) break;
1559 if (j->r.deadline_at >= nanoseconds()) break;
15621560
15631561 /* This job is in the middle of being written out. If we return it to
15641562 * the ready queue, someone might free it before we finish writing it
15691567 }
15701568
15711569 timeout_ct++; /* stats */
1572 j->timeout_ct++;
1573 r = enqueue_job(remove_this_reserved_job(c, j), 0, 0);
1574 if (r < 1) bury_job(j, 0); /* out of memory, so bury it */
1575 r = conn_update_evq(c, c->evq.ev_events);
1576 if (r == -1) return twarnx("conn_update_evq() failed"), conn_close(c);
1570 j->r.timeout_ct++;
1571 r = enqueue_job(c->srv, remove_this_reserved_job(c, j), 0, 0);
1572 if (r < 1) bury_job(c->srv, j, 0); /* out of memory, so bury it */
1573 connsched(c);
15771574 }
15781575
15791576 if (should_timeout) {
1580 dprintf("conn_waiting(%p) = %d\n", c, conn_waiting(c));
15811577 return reply_msg(remove_waiting_conn(c), MSG_DEADLINE_SOON);
15821578 } else if (conn_waiting(c) && c->pending_timeout >= 0) {
1583 dprintf("conn_waiting(%p) = %d\n", c, conn_waiting(c));
15841579 c->pending_timeout = -1;
15851580 return reply_msg(remove_waiting_conn(c), MSG_TIMED_OUT);
15861581 }
16021597 static void
16031598 reset_conn(conn c)
16041599 {
1605 int r;
1606
1607 r = conn_update_evq(c, EV_READ | EV_PERSIST);
1608 if (r == -1) return twarnx("update events failed"), conn_close(c);
1600 connwant(c, 'r', &dirty);
16091601
16101602 /* was this a peek or stats command? */
1611 if (c->out_job && c->out_job->state == JOB_STATE_COPY) job_free(c->out_job);
1603 if (c->out_job && c->out_job->r.state == Copy) job_free(c->out_job);
16121604 c->out_job = NULL;
16131605
16141606 c->reply_sent = 0; /* now that we're done, reset this */
16161608 }
16171609
16181610 static void
1619 h_conn_data(conn c)
1611 conn_data(conn c)
16201612 {
16211613 int r, to_read;
16221614 job j;
16241616
16251617 switch (c->state) {
16261618 case STATE_WANTCOMMAND:
1627 r = read(c->fd, c->cmd + c->cmd_read, LINE_BUF_SIZE - c->cmd_read);
1619 r = read(c->sock.fd, c->cmd + c->cmd_read, LINE_BUF_SIZE - c->cmd_read);
16281620 if (r == -1) return check_err(c, "read()");
16291621 if (r == 0) return conn_close(c); /* the client hung up */
16301622
16491641 /* Invert the meaning of in_job_read while throwing away data -- it
16501642 * counts the bytes that remain to be thrown away. */
16511643 to_read = min(c->in_job_read, BUCKET_BUF_SIZE);
1652 r = read(c->fd, bucket, to_read);
1644 r = read(c->sock.fd, bucket, to_read);
16531645 if (r == -1) return check_err(c, "read()");
16541646 if (r == 0) return conn_close(c); /* the client hung up */
16551647
16641656 case STATE_WANTDATA:
16651657 j = c->in_job;
16661658
1667 r = read(c->fd, j->body + c->in_job_read, j->body_size -c->in_job_read);
1659 r = read(c->sock.fd, j->body + c->in_job_read, j->r.body_size -c->in_job_read);
16681660 if (r == -1) return check_err(c, "read()");
16691661 if (r == 0) return conn_close(c); /* the client hung up */
16701662
16711663 c->in_job_read += r; /* we got some bytes */
16721664
1673 /* (j->in_job_read > j->body_size) can't happen */
1665 /* (j->in_job_read > j->r.body_size) can't happen */
16741666
16751667 maybe_enqueue_incoming_job(c);
16761668 break;
16771669 case STATE_SENDWORD:
1678 r= write(c->fd, c->reply + c->reply_sent, c->reply_len - c->reply_sent);
1670 r= write(c->sock.fd, c->reply + c->reply_sent, c->reply_len - c->reply_sent);
16791671 if (r == -1) return check_err(c, "write()");
16801672 if (r == 0) return conn_close(c); /* the client hung up */
16811673
16931685 iov[0].iov_base = (void *)(c->reply + c->reply_sent);
16941686 iov[0].iov_len = c->reply_len - c->reply_sent; /* maybe 0 */
16951687 iov[1].iov_base = j->body + c->out_job_sent;
1696 iov[1].iov_len = j->body_size - c->out_job_sent;
1697
1698 r = writev(c->fd, iov, 2);
1688 iov[1].iov_len = j->r.body_size - c->out_job_sent;
1689
1690 r = writev(c->sock.fd, iov, 2);
16991691 if (r == -1) return check_err(c, "writev()");
17001692 if (r == 0) return conn_close(c); /* the client hung up */
17011693
17061698 c->reply_sent = c->reply_len;
17071699 }
17081700
1709 /* (c->out_job_sent > j->body_size) can't happen */
1701 /* (c->out_job_sent > j->r.body_size) can't happen */
17101702
17111703 /* are we done? */
1712 if (c->out_job_sent == j->body_size) return reset_conn(c);
1704 if (c->out_job_sent == j->r.body_size) {
1705 if (verbose >= 2) {
1706 printf(">%d job %"PRIu64"\n", c->sock.fd, j->r.id);
1707 }
1708 return reset_conn(c);
1709 }
17131710
17141711 /* otherwise we sent incomplete data, so just keep waiting */
17151712 break;
1716 case STATE_WAIT: /* keep an eye out in case they hang up */
1717 /* but don't hang up just because our buffer is full */
1718 if (LINE_BUF_SIZE - c->cmd_read < 1) break;
1719
1720 r = read(c->fd, c->cmd + c->cmd_read, LINE_BUF_SIZE - c->cmd_read);
1721 if (r == -1) return check_err(c, "read()");
1722 if (r == 0) return conn_close(c); /* the client hung up */
1723 c->cmd_read += r; /* we got some bytes */
1724 }
1725 }
1726
1727 #define want_command(c) ((c)->fd && ((c)->state == STATE_WANTCOMMAND))
1713 case STATE_WAIT:
1714 // nothing
1715 break;
1716 }
1717 }
1718
1719 #define want_command(c) ((c)->sock.fd && ((c)->state == STATE_WANTCOMMAND))
17281720 #define cmd_data_ready(c) (want_command(c) && (c)->cmd_read)
17291721
17301722 static void
1723 update_conns()
1724 {
1725 int r;
1726 conn c;
1727
1728 while ((c = conn_remove(dirty.next))) { /* assignment */
1729 r = sockwant(&c->sock, c->rw);
1730 if (r == -1) {
1731 twarn("sockwant");
1732 conn_close(c);
1733 }
1734 }
1735 }
1736
1737 static void
17311738 h_conn(const int fd, const short which, conn c)
17321739 {
1733 if (fd != c->fd) {
1740 if (fd != c->sock.fd) {
17341741 twarnx("Argh! event fd doesn't match conn fd.");
17351742 close(fd);
1736 return conn_close(c);
1737 }
1738
1739 switch (which) {
1740 case EV_TIMEOUT:
1741 h_conn_timeout(c);
1742 event_add(&c->evq, NULL); /* seems to be necessary */
1743 break;
1744 case EV_READ:
1745 /* fall through... */
1746 case EV_WRITE:
1747 /* fall through... */
1748 default:
1749 h_conn_data(c);
1750 }
1751
1743 conn_close(c);
1744 update_conns();
1745 return;
1746 }
1747
1748 if (which == 'h') {
1749 conn_close(c);
1750 return;
1751 }
1752
1753 conn_data(c);
17521754 while (cmd_data_ready(c) && (c->cmd_len = cmd_len(c))) do_cmd(c);
1753 }
1754
1755 static void
1756 h_delay()
1755 update_conns();
1756 }
1757
1758 static void
1759 prothandle(conn c, int ev)
1760 {
1761 h_conn(c->sock.fd, ev, c);
1762 }
1763
1764 void
1765 prottick(Srv *s)
17571766 {
17581767 int r;
17591768 job j;
1760 usec now;
1769 int64 now;
17611770 int i;
17621771 tube t;
17631772
1764 now = now_usec();
1773 now = nanoseconds();
17651774 while ((j = delay_q_peek())) {
1766 if (j->deadline_at > now) break;
1775 if (j->r.deadline_at > now) break;
17671776 j = delay_q_take();
1768 r = enqueue_job(j, 0, 0);
1769 if (r < 1) bury_job(j, 0); /* out of memory, so bury it */
1777 r = enqueue_job(s, j, 0, 0);
1778 if (r < 1) bury_job(s, j, 0); /* out of memory, so bury it */
17701779 }
17711780
17721781 for (i = 0; i < tubes.used; i++) {
17731782 t = tubes.items[i];
17741783
1775 dprintf("h_delay for %s t->waiting.used=%zu t->ready.used=%d t->pause=%" PRIu64 "\n",
1776 t->name, t->waiting.used, t->ready.used, t->pause);
17771784 if (t->pause && t->deadline_at <= now) {
17781785 t->pause = 0;
17791786 process_queue();
17801787 }
17811788 }
17821789
1783 set_main_delay_timeout();
1790 while (s->conns.len) {
1791 conn c = s->conns.data[0];
1792 if (c->tickat > now) {
1793 break;
1794 }
1795
1796 heapremove(&s->conns, 0);
1797 conn_timeout(c);
1798 }
1799
1800 update_conns();
17841801 }
17851802
17861803 void
1787 h_accept(const int fd, const short which, struct event *ev)
1804 h_accept(const int fd, const short which, Srv *s)
17881805 {
17891806 conn c;
17901807 int cfd, flags, r;
17911808 socklen_t addrlen;
17921809 struct sockaddr_in6 addr;
17931810
1794 if (which == EV_TIMEOUT) return h_delay();
1795
17961811 addrlen = sizeof addr;
17971812 cfd = accept(fd, (struct sockaddr *)&addr, &addrlen);
17981813 if (cfd == -1) {
17991814 if (errno != EAGAIN && errno != EWOULDBLOCK) twarn("accept()");
1800 if (errno == EMFILE) brake();
1815 update_conns();
18011816 return;
18021817 }
1818 if (verbose) {
1819 printf("accept %d\n", cfd);
1820 }
18031821
18041822 flags = fcntl(cfd, F_GETFL, 0);
1805 if (flags < 0) return twarn("getting flags"), close(cfd), v();
1823 if (flags < 0) {
1824 twarn("getting flags");
1825 close(cfd);
1826 if (verbose) {
1827 printf("close %d\n", cfd);
1828 }
1829 update_conns();
1830 return;
1831 }
18061832
18071833 r = fcntl(cfd, F_SETFL, flags | O_NONBLOCK);
1808 if (r < 0) return twarn("setting O_NONBLOCK"), close(cfd), v();
1834 if (r < 0) {
1835 twarn("setting O_NONBLOCK");
1836 close(cfd);
1837 if (verbose) {
1838 printf("close %d\n", cfd);
1839 }
1840 update_conns();
1841 return;
1842 }
18091843
18101844 c = make_conn(cfd, STATE_WANTCOMMAND, default_tube, default_tube);
1811 if (!c) return twarnx("make_conn() failed"), close(cfd), brake();
1812
1813 dprintf("accepted conn, fd=%d\n", cfd);
1814 r = conn_set_evq(c, EV_READ | EV_PERSIST, (evh) h_conn);
1815 if (r == -1) return twarnx("conn_set_evq() failed"), close(cfd), brake();
1845 if (!c) {
1846 twarnx("make_conn() failed");
1847 close(cfd);
1848 if (verbose) {
1849 printf("close %d\n", cfd);
1850 }
1851 update_conns();
1852 return;
1853 }
1854 c->srv = s;
1855 c->sock.x = c;
1856 c->sock.f = (Handle)prothandle;
1857 c->sock.fd = cfd;
1858
1859 r = sockwant(&c->sock, 'r');
1860 if (r == -1) {
1861 twarn("sockwant");
1862 close(cfd);
1863 if (verbose) {
1864 printf("close %d\n", cfd);
1865 }
1866 update_conns();
1867 return;
1868 }
1869 update_conns();
18161870 }
18171871
18181872 void
18191873 prot_init()
18201874 {
1821 started_at = now_usec();
1875 started_at = nanoseconds();
18221876 memset(op_ct, 0, sizeof(op_ct));
18231877
18241878 ms_init(&tubes, NULL, NULL);
18281882 }
18291883
18301884 void
1831 prot_replay_binlog(job binlog_jobs)
1885 prot_replay(Srv *s, job list)
18321886 {
18331887 job j, nj;
1834 usec delay;
1888 int64 t, delay;
18351889 int r;
18361890
1837 for (j = binlog_jobs->next ; j != binlog_jobs ; j = nj) {
1891 for (j = list->next ; j != list ; j = nj) {
18381892 nj = j->next;
18391893 job_remove(j);
1840 binlog_reserve_space_update(j); /* reserve space for a delete */
1894 walresvupdate(&s->wal, j); /* reserve space for a delete */
18411895 delay = 0;
1842 switch (j->state) {
1843 case JOB_STATE_BURIED:
1844 bury_job(j, 0);
1896 switch (j->r.state) {
1897 case Buried:
1898 bury_job(s, j, 0);
18451899 break;
1846 case JOB_STATE_DELAYED:
1847 if (started_at < j->deadline_at) {
1848 delay = j->deadline_at - started_at;
1900 case Delayed:
1901 t = nanoseconds();
1902 if (t < j->r.deadline_at) {
1903 delay = j->r.deadline_at - t;
18491904 }
18501905 /* fall through */
18511906 default:
1852 r = enqueue_job(j, delay, 0);
1853 if (r < 1) twarnx("error processing binlog job %llu", j->id);
1854 }
1855 }
1856 }
1907 r = enqueue_job(s, j, delay, 0);
1908 if (r < 1) twarnx("error recovering job %"PRIu64, j->r.id);
1909 }
1910 }
1911 }
+0
-40
prot.h less more
0 /* prot.h - protocol implementation header */
1
2 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef prot_h
19 #define prot_h
20
21 #include "conn.h"
22
23 #define URGENT_THRESHOLD 1024
24 #define JOB_DATA_SIZE_LIMIT_DEFAULT ((1 << 16) - 1)
25
26 extern size_t job_data_size_limit;
27
28 void prot_init();
29
30 conn remove_waiting_conn(conn c);
31
32 void enqueue_reserved_jobs(conn c);
33
34 void enter_drain_mode(int sig);
35 void h_accept(const int fd, const short which, struct event *ev);
36 void prot_remove_tube(tube t);
37 void prot_replay_binlog(job binlog_jobs);
38
39 #endif /*prot_h*/
+0
-135
scripts/beanstalkd.init less more
0 #!/bin/sh
1 #
2 # beanstalkd - a simple, fast workqueue service
3 #
4 # chkconfig: - 57 47
5 # description: a simple, fast workqueue service
6 # processname: beanstalkd
7 # config: /etc/sysconfig/beanstalkd
8 #
9
10 ### BEGIN INIT INFO
11 # Provides: beanstalkd
12 # Required-Start: $local_fs $network $remote_fs
13 # Required-Stop: $local_fs $network $remote_fs
14 # Short-Description: start and stop beanstalkd
15 # Description: a simple, fast workqueue service
16 ### END INIT INFO
17
18 # Source function library.
19 . /etc/rc.d/init.d/functions
20
21 # Source networking configuration.
22 . /etc/sysconfig/network
23
24 # Check that networking is up.
25 [ "$NETWORKING" = "no" ] && exit
26 exec="/usr/bin/beanstalkd"
27 prog=$(basename $exec)
28
29 # default options, overruled by items in sysconfig
30 BEANSTALKD_ADDR=0.0.0.0
31 BEANSTALKD_PORT=11300
32 BEANSTALKD_USER=beanstalkd
33
34 [ -e /etc/sysconfig/beanstalkd ] && . /etc/sysconfig/beanstalkd
35
36 lockfile=/var/lock/subsys/beanstalkd
37
38 start() {
39 [ -x $exec ] || exit 5
40 echo -n $"Starting $prog: "
41 # if not running, start it up here, usually something like "daemon $exec"
42 options="-l ${BEANSTALKD_ADDR} -p ${BEANSTALKD_PORT} -u ${BEANSTALKD_USER}"
43 if [ "${BEANSTALKD_MAX_JOB_SIZE}" != "" ]; then
44 options="${options} -z ${BEANSTALKD_MAX_JOB_SIZE}"
45 fi
46
47 if [ "${BEANSTALKD_BINLOG_DIR}" != "" ]; then
48 if [ ! -d "${BEANSTALKD_BINLOG_DIR}" ]; then
49 echo "Creating binlog directory (${BEANSTALKD_BINLOG_DIR})"
50 mkdir -p ${BEANSTALKD_BINLOG_DIR} && chown ${BEANSTALKD_USER}:${BEANSTALKD_USER} ${BEANSTALKD_BINLOG_DIR}
51 fi
52 options="${options} -b ${BEANSTALKD_BINLOG_DIR}"
53 if [ "${BEANSTALKD_BINLOG_FSYNC_PERIOD}" != "" ]; then
54 options="${options} -f ${BEANSTALKD_BINLOG_FSYNC_PERIOD}"
55 else
56 options="${options} -F"
57 fi
58 if [ "${BEANSTALKD_BINLOG_SIZE}" != "" ]; then
59 options="${options} -s ${BEANSTALKD_BINLOG_SIZE}"
60 fi
61 fi
62
63 daemon $exec -d $options
64 retval=$?
65 echo
66 [ $retval -eq 0 ] && touch $lockfile
67 return $retval
68 }
69
70 stop() {
71 echo -n $"Stopping $prog: "
72 # stop it here, often "killproc $prog"
73 killproc $prog -INT
74 retval=$?
75 echo
76 [ $retval -eq 0 ] && rm -f $lockfile
77 return $retval
78 }
79
80 restart() {
81 stop
82 start
83 }
84
85 reload() {
86 restart
87 }
88
89 force_reload() {
90 restart
91 }
92
93 rh_status() {
94 # run checks to determine if the service is running or use generic status
95 status $prog
96 }
97
98 rh_status_q() {
99 rh_status >/dev/null 2>&1
100 }
101
102
103 case "$1" in
104 start)
105 rh_status_q && exit 0
106 $1
107 ;;
108 stop)
109 rh_status_q || exit 0
110 $1
111 ;;
112 restart)
113 $1
114 ;;
115 reload)
116 rh_status_q || exit 7
117 $1
118 ;;
119 force-reload)
120 force_reload
121 ;;
122 status)
123 rh_status
124 ;;
125 condrestart|try-restart)
126 rh_status_q || exit 0
127 restart
128 ;;
129 *)
130 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
131 exit 2
132 esac
133 exit $?
134
+0
-28
scripts/beanstalkd.sysconfig less more
0 # System configuration for the beanstalkd daemon
1
2 # Available options correspond to the options to the
3 # beanstalkd commandline.
4
5 BEANSTALKD_ADDR=0.0.0.0
6 BEANSTALKD_PORT=11300
7 BEANSTALKD_USER=beanstalkd
8
9 # Job size is left to the default. Uncomment and set it
10 # to a value to have it take affect.
11 #BEANSTALKD_MAX_JOB_SIZE=65535
12
13 # Using the binlog is off by default.
14 #
15 # The direcory to house the binlog. This will be created
16 # if it does not exist
17 #BEANSTALKD_BINLOG_DIR=/var/lib/beanstalkd/binlog
18 #
19 # fsync the binlog at most once every N milliseconds.
20 # setting this to 0 means 'always fsync'. If this is unset,
21 # and the binlog is used, then no explicit fsync is ever
22 # performed. That is, the -F option is used.
23 #BEANSTALKD_BINLOG_FSYNC_PERIOD=
24 #
25 # The size of each binlog file. This is rounded
26 # up to the nearest 512 byte boundary.
27 #BEANSTALKD_BINLOG_SIZE=10485760
0 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
1
2 /***
3 Copyright 2010 Lennart Poettering
4
5 Permission is hereby granted, free of charge, to any person
6 obtaining a copy of this software and associated documentation files
7 (the "Software"), to deal in the Software without restriction,
8 including without limitation the rights to use, copy, modify, merge,
9 publish, distribute, sublicense, and/or sell copies of the Software,
10 and to permit persons to whom the Software is furnished to do so,
11 subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be
14 included in all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 ***/
25
26 #ifndef _GNU_SOURCE
27 #define _GNU_SOURCE
28 #endif
29
30 #include <sys/types.h>
31 #include <sys/stat.h>
32 #include <sys/socket.h>
33 #include <sys/un.h>
34 #include <sys/fcntl.h>
35 #include <netinet/in.h>
36 #include <stdlib.h>
37 #include <errno.h>
38 #include <unistd.h>
39 #include <string.h>
40 #include <stdarg.h>
41 #include <stdio.h>
42
43 #include "sd-daemon.h"
44
45 int sd_listen_fds(int unset_environment) {
46
47 #if defined(DISABLE_SYSTEMD) || !defined(__linux__)
48 return 0;
49 #else
50 int r, fd;
51 const char *e;
52 char *p = NULL;
53 unsigned long l;
54
55 if (!(e = getenv("LISTEN_PID"))) {
56 r = 0;
57 goto finish;
58 }
59
60 errno = 0;
61 l = strtoul(e, &p, 10);
62
63 if (errno != 0) {
64 r = -errno;
65 goto finish;
66 }
67
68 if (!p || *p || l <= 0) {
69 r = -EINVAL;
70 goto finish;
71 }
72
73 /* Is this for us? */
74 if (getpid() != (pid_t) l) {
75 r = 0;
76 goto finish;
77 }
78
79 if (!(e = getenv("LISTEN_FDS"))) {
80 r = 0;
81 goto finish;
82 }
83
84 errno = 0;
85 l = strtoul(e, &p, 10);
86
87 if (errno != 0) {
88 r = -errno;
89 goto finish;
90 }
91
92 if (!p || *p) {
93 r = -EINVAL;
94 goto finish;
95 }
96
97 for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int) l; fd ++) {
98 int flags;
99
100 if ((flags = fcntl(fd, F_GETFD)) < 0) {
101 r = -errno;
102 goto finish;
103 }
104
105 if (flags & FD_CLOEXEC)
106 continue;
107
108 if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
109 r = -errno;
110 goto finish;
111 }
112 }
113
114 r = (int) l;
115
116 finish:
117 if (unset_environment) {
118 unsetenv("LISTEN_PID");
119 unsetenv("LISTEN_FDS");
120 }
121
122 return r;
123 #endif
124 }
125
126 int sd_is_fifo(int fd, const char *path) {
127 struct stat st_fd;
128
129 if (fd < 0)
130 return -EINVAL;
131
132 memset(&st_fd, 0, sizeof(st_fd));
133 if (fstat(fd, &st_fd) < 0)
134 return -errno;
135
136 if (!S_ISFIFO(st_fd.st_mode))
137 return 0;
138
139 if (path) {
140 struct stat st_path;
141
142 memset(&st_path, 0, sizeof(st_path));
143 if (stat(path, &st_path) < 0) {
144
145 if (errno == ENOENT || errno == ENOTDIR)
146 return 0;
147
148 return -errno;
149 }
150
151 return
152 st_path.st_dev == st_fd.st_dev &&
153 st_path.st_ino == st_fd.st_ino;
154 }
155
156 return 1;
157 }
158
159 static int sd_is_socket_internal(int fd, int type, int listening) {
160 struct stat st_fd;
161
162 if (fd < 0 || type < 0)
163 return -EINVAL;
164
165 if (fstat(fd, &st_fd) < 0)
166 return -errno;
167
168 if (!S_ISSOCK(st_fd.st_mode))
169 return 0;
170
171 if (type != 0) {
172 int other_type = 0;
173 socklen_t l = sizeof(other_type);
174
175 if (getsockopt(fd, SOL_SOCKET, SO_TYPE, &other_type, &l) < 0)
176 return -errno;
177
178 if (l != sizeof(other_type))
179 return -EINVAL;
180
181 if (other_type != type)
182 return 0;
183 }
184
185 if (listening >= 0) {
186 int accepting = 0;
187 socklen_t l = sizeof(accepting);
188
189 if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &accepting, &l) < 0)
190 return -errno;
191
192 if (l != sizeof(accepting))
193 return -EINVAL;
194
195 if (!accepting != !listening)
196 return 0;
197 }
198
199 return 1;
200 }
201
202 union sockaddr_union {
203 struct sockaddr sa;
204 struct sockaddr_in in4;
205 struct sockaddr_in6 in6;
206 struct sockaddr_un un;
207 struct sockaddr_storage storage;
208 };
209
210 int sd_is_socket(int fd, int family, int type, int listening) {
211 int r;
212
213 if (family < 0)
214 return -EINVAL;
215
216 if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
217 return r;
218
219 if (family > 0) {
220 union sockaddr_union sockaddr;
221 socklen_t l;
222
223 memset(&sockaddr, 0, sizeof(sockaddr));
224 l = sizeof(sockaddr);
225
226 if (getsockname(fd, &sockaddr.sa, &l) < 0)
227 return -errno;
228
229 if (l < sizeof(sa_family_t))
230 return -EINVAL;
231
232 return sockaddr.sa.sa_family == family;
233 }
234
235 return 1;
236 }
237
238 int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) {
239 union sockaddr_union sockaddr;
240 socklen_t l;
241 int r;
242
243 if (family != 0 && family != AF_INET && family != AF_INET6)
244 return -EINVAL;
245
246 if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
247 return r;
248
249 memset(&sockaddr, 0, sizeof(sockaddr));
250 l = sizeof(sockaddr);
251
252 if (getsockname(fd, &sockaddr.sa, &l) < 0)
253 return -errno;
254
255 if (l < sizeof(sa_family_t))
256 return -EINVAL;
257
258 if (sockaddr.sa.sa_family != AF_INET &&
259 sockaddr.sa.sa_family != AF_INET6)
260 return 0;
261
262 if (family > 0)
263 if (sockaddr.sa.sa_family != family)
264 return 0;
265
266 if (port > 0) {
267 if (sockaddr.sa.sa_family == AF_INET) {
268 if (l < sizeof(struct sockaddr_in))
269 return -EINVAL;
270
271 return htons(port) == sockaddr.in4.sin_port;
272 } else {
273 if (l < sizeof(struct sockaddr_in6))
274 return -EINVAL;
275
276 return htons(port) == sockaddr.in6.sin6_port;
277 }
278 }
279
280 return 1;
281 }
282
283 int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) {
284 union sockaddr_union sockaddr;
285 socklen_t l;
286 int r;
287
288 if ((r = sd_is_socket_internal(fd, type, listening)) <= 0)
289 return r;
290
291 memset(&sockaddr, 0, sizeof(sockaddr));
292 l = sizeof(sockaddr);
293
294 if (getsockname(fd, &sockaddr.sa, &l) < 0)
295 return -errno;
296
297 if (l < sizeof(sa_family_t))
298 return -EINVAL;
299
300 if (sockaddr.sa.sa_family != AF_UNIX)
301 return 0;
302
303 if (path) {
304 if (length <= 0)
305 length = strlen(path);
306
307 if (length <= 0)
308 /* Unnamed socket */
309 return l == sizeof(sa_family_t);
310
311 if (path[0])
312 /* Normal path socket */
313 return
314 (l >= sizeof(sa_family_t) + length + 1) &&
315 memcmp(path, sockaddr.un.sun_path, length+1) == 0;
316 else
317 /* Abstract namespace socket */
318 return
319 (l == sizeof(sa_family_t) + length) &&
320 memcmp(path, sockaddr.un.sun_path, length) == 0;
321 }
322
323 return 1;
324 }
325
326 int sd_notify(int unset_environment, const char *state) {
327 #if defined(DISABLE_SYSTEMD) || !defined(__linux__) || !defined(SOCK_CLOEXEC)
328 return 0;
329 #else
330 int fd = -1, r;
331 struct msghdr msghdr;
332 struct iovec iovec;
333 union sockaddr_union sockaddr;
334 const char *e;
335
336 if (!state) {
337 r = -EINVAL;
338 goto finish;
339 }
340
341 if (!(e = getenv("NOTIFY_SOCKET")))
342 return 0;
343
344 /* Must be an abstract socket, or an absolute path */
345 if ((e[0] != '@' && e[0] != '/') || e[1] == 0) {
346 r = -EINVAL;
347 goto finish;
348 }
349
350 if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) {
351 r = -errno;
352 goto finish;
353 }
354
355 memset(&sockaddr, 0, sizeof(sockaddr));
356 sockaddr.sa.sa_family = AF_UNIX;
357 strncpy(sockaddr.un.sun_path, e, sizeof(sockaddr.un.sun_path));
358
359 if (sockaddr.un.sun_path[0] == '@')
360 sockaddr.un.sun_path[0] = 0;
361
362 memset(&iovec, 0, sizeof(iovec));
363 iovec.iov_base = (char*) state;
364 iovec.iov_len = strlen(state);
365
366 memset(&msghdr, 0, sizeof(msghdr));
367 msghdr.msg_name = &sockaddr;
368 msghdr.msg_namelen = sizeof(sa_family_t) + strlen(e);
369
370 if (msghdr.msg_namelen > sizeof(struct sockaddr_un))
371 msghdr.msg_namelen = sizeof(struct sockaddr_un);
372
373 msghdr.msg_iov = &iovec;
374 msghdr.msg_iovlen = 1;
375
376 if (sendmsg(fd, &msghdr, MSG_NOSIGNAL) < 0) {
377 r = -errno;
378 goto finish;
379 }
380
381 r = 1;
382
383 finish:
384 if (unset_environment)
385 unsetenv("NOTIFY_SOCKET");
386
387 if (fd >= 0)
388 close(fd);
389
390 return r;
391 #endif
392 }
393
394 int sd_notifyf(int unset_environment, const char *format, ...) {
395 #if defined(DISABLE_SYSTEMD) || !defined(__linux__)
396 return 0;
397 #else
398 va_list ap;
399 char *p = NULL;
400 int r;
401
402 va_start(ap, format);
403 r = vasprintf(&p, format, ap);
404 va_end(ap);
405
406 if (r < 0 || !p)
407 return -ENOMEM;
408
409 r = sd_notify(unset_environment, p);
410 free(p);
411
412 return r;
413 #endif
414 }
415
416 int sd_booted(void) {
417 #if defined(DISABLE_SYSTEMD) || !defined(__linux__)
418 return 0;
419 #else
420
421 struct stat a, b;
422
423 /* We simply test whether the systemd cgroup hierarchy is
424 * mounted */
425
426 if (lstat("/sys/fs/cgroup", &a) < 0)
427 return 0;
428
429 if (lstat("/sys/fs/cgroup/systemd", &b) < 0)
430 return 0;
431
432 return a.st_dev != b.st_dev;
433 #endif
434 }
0 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
1
2 #ifndef foosddaemonhfoo
3 #define foosddaemonhfoo
4
5 /***
6 Copyright 2010 Lennart Poettering
7
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated documentation files
10 (the "Software"), to deal in the Software without restriction,
11 including without limitation the rights to use, copy, modify, merge,
12 publish, distribute, sublicense, and/or sell copies of the Software,
13 and to permit persons to whom the Software is furnished to do so,
14 subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 SOFTWARE.
27 ***/
28
29 #include <sys/types.h>
30 #include <inttypes.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /*
37 Reference implementation of a few systemd related interfaces for
38 writing daemons. These interfaces are trivial to implement. To
39 simplify porting we provide this reference implementation.
40 Applications are welcome to reimplement the algorithms described
41 here if they do not want to include these two source files.
42
43 The following functionality is provided:
44
45 - Support for logging with log levels on stderr
46 - File descriptor passing for socket-based activation
47 - Daemon startup and status notification
48 - Detection of systemd boots
49
50 You may compile this with -DDISABLE_SYSTEMD to disable systemd
51 support. This makes all those calls NOPs that are directly related to
52 systemd (i.e. only sd_is_xxx() will stay useful).
53
54 Since this is drop-in code we don't want any of our symbols to be
55 exported in any case. Hence we declare hidden visibility for all of
56 them.
57
58 You may find an up-to-date version of these source files online:
59
60 http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.h
61 http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c
62
63 This should compile on non-Linux systems, too, but with the
64 exception of the sd_is_xxx() calls all functions will become NOPs.
65
66 See sd-daemon(7) for more information.
67 */
68
69 #if __GNUC__ >= 4
70 #define _sd_printf_attr_(a,b) __attribute__ ((format (printf, a, b)))
71 #else
72 #define _sd_printf_attr_(a,b)
73 #endif
74
75 #if (__GNUC__ >= 4) && !defined(SD_EXPORT_SYMBOLS)
76 #define _sd_hidden_ __attribute__ ((visibility("hidden")))
77 #else
78 #define _sd_hidden_
79 #endif
80
81 /*
82 Log levels for usage on stderr:
83
84 fprintf(stderr, SD_NOTICE "Hello World!\n");
85
86 This is similar to printk() usage in the kernel.
87 */
88 #define SD_EMERG "<0>" /* system is unusable */
89 #define SD_ALERT "<1>" /* action must be taken immediately */
90 #define SD_CRIT "<2>" /* critical conditions */
91 #define SD_ERR "<3>" /* error conditions */
92 #define SD_WARNING "<4>" /* warning conditions */
93 #define SD_NOTICE "<5>" /* normal but significant condition */
94 #define SD_INFO "<6>" /* informational */
95 #define SD_DEBUG "<7>" /* debug-level messages */
96
97 /* The first passed file descriptor is fd 3 */
98 #define SD_LISTEN_FDS_START 3
99
100 /*
101 Returns how many file descriptors have been passed, or a negative
102 errno code on failure. Optionally, removes the $LISTEN_FDS and
103 $LISTEN_PID file descriptors from the environment (recommended, but
104 problematic in threaded environments). If r is the return value of
105 this function you'll find the file descriptors passed as fds
106 SD_LISTEN_FDS_START to SD_LISTEN_FDS_START+r-1. Returns a negative
107 errno style error code on failure. This function call ensures that
108 the FD_CLOEXEC flag is set for the passed file descriptors, to make
109 sure they are not passed on to child processes. If FD_CLOEXEC shall
110 not be set, the caller needs to unset it after this call for all file
111 descriptors that are used.
112
113 See sd_listen_fds(3) for more information.
114 */
115 int sd_listen_fds(int unset_environment) _sd_hidden_;
116
117 /*
118 Helper call for identifying a passed file descriptor. Returns 1 if
119 the file descriptor is a FIFO in the file system stored under the
120 specified path, 0 otherwise. If path is NULL a path name check will
121 not be done and the call only verifies if the file descriptor
122 refers to a FIFO. Returns a negative errno style error code on
123 failure.
124
125 See sd_is_fifo(3) for more information.
126 */
127 int sd_is_fifo(int fd, const char *path) _sd_hidden_;
128
129 /*
130 Helper call for identifying a passed file descriptor. Returns 1 if
131 the file descriptor is a socket of the specified family (AF_INET,
132 ...) and type (SOCK_DGRAM, SOCK_STREAM, ...), 0 otherwise. If
133 family is 0 a socket family check will not be done. If type is 0 a
134 socket type check will not be done and the call only verifies if
135 the file descriptor refers to a socket. If listening is > 0 it is
136 verified that the socket is in listening mode. (i.e. listen() has
137 been called) If listening is == 0 it is verified that the socket is
138 not in listening mode. If listening is < 0 no listening mode check
139 is done. Returns a negative errno style error code on failure.
140
141 See sd_is_socket(3) for more information.
142 */
143 int sd_is_socket(int fd, int family, int type, int listening) _sd_hidden_;
144
145 /*
146 Helper call for identifying a passed file descriptor. Returns 1 if
147 the file descriptor is an Internet socket, of the specified family
148 (either AF_INET or AF_INET6) and the specified type (SOCK_DGRAM,
149 SOCK_STREAM, ...), 0 otherwise. If version is 0 a protocol version
150 check is not done. If type is 0 a socket type check will not be
151 done. If port is 0 a socket port check will not be done. The
152 listening flag is used the same way as in sd_is_socket(). Returns a
153 negative errno style error code on failure.
154
155 See sd_is_socket_inet(3) for more information.
156 */
157 int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) _sd_hidden_;
158
159 /*
160 Helper call for identifying a passed file descriptor. Returns 1 if
161 the file descriptor is an AF_UNIX socket of the specified type
162 (SOCK_DGRAM, SOCK_STREAM, ...) and path, 0 otherwise. If type is 0
163 a socket type check will not be done. If path is NULL a socket path
164 check will not be done. For normal AF_UNIX sockets set length to
165 0. For abstract namespace sockets set length to the length of the
166 socket name (including the initial 0 byte), and pass the full
167 socket path in path (including the initial 0 byte). The listening
168 flag is used the same way as in sd_is_socket(). Returns a negative
169 errno style error code on failure.
170
171 See sd_is_socket_unix(3) for more information.
172 */
173 int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) _sd_hidden_;
174
175 /*
176 Informs systemd about changed daemon state. This takes a number of
177 newline separated environment-style variable assignments in a
178 string. The following variables are known:
179
180 READY=1 Tells systemd that daemon startup is finished (only
181 relevant for services of Type=notify). The passed
182 argument is a boolean "1" or "0". Since there is
183 little value in signalling non-readiness the only
184 value daemons should send is "READY=1".
185
186 STATUS=... Passes a single-line status string back to systemd
187 that describes the daemon state. This is free-from
188 and can be used for various purposes: general state
189 feedback, fsck-like programs could pass completion
190 percentages and failing programs could pass a human
191 readable error message. Example: "STATUS=Completed
192 66% of file system check..."
193
194 ERRNO=... If a daemon fails, the errno-style error code,
195 formatted as string. Example: "ERRNO=2" for ENOENT.
196
197 BUSERROR=... If a daemon fails, the D-Bus error-style error
198 code. Example: "BUSERROR=org.freedesktop.DBus.Error.TimedOut"
199
200 MAINPID=... The main pid of a daemon, in case systemd did not
201 fork off the process itself. Example: "MAINPID=4711"
202
203 Daemons can choose to send additional variables. However, it is
204 recommened to prefix variable names not listed above with X_.
205
206 Returns a negative errno-style error code on failure. Returns > 0
207 if systemd could be notified, 0 if it couldn't possibly because
208 systemd is not running.
209
210 Example: When a daemon finished starting up, it could issue this
211 call to notify systemd about it:
212
213 sd_notify(0, "READY=1");
214
215 See sd_notifyf() for more complete examples.
216
217 See sd_notify(3) for more information.
218 */
219 int sd_notify(int unset_environment, const char *state) _sd_hidden_;
220
221 /*
222 Similar to sd_notify() but takes a format string.
223
224 Example 1: A daemon could send the following after initialization:
225
226 sd_notifyf(0, "READY=1\n"
227 "STATUS=Processing requests...\n"
228 "MAINPID=%lu",
229 (unsigned long) getpid());
230
231 Example 2: A daemon could send the following shortly before
232 exiting, on failure:
233
234 sd_notifyf(0, "STATUS=Failed to start up: %s\n"
235 "ERRNO=%i",
236 strerror(errno),
237 errno);
238
239 See sd_notifyf(3) for more information.
240 */
241 int sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(2,3) _sd_hidden_;
242
243 /*
244 Returns > 0 if the system was booted with systemd. Returns < 0 on
245 error. Returns 0 if the system was not booted with systemd. Note
246 that all of the functions above handle non-systemd boots just
247 fine. You should NOT protect them with a call to this function. Also
248 note that this function checks whether the system, not the user
249 session is controlled by systemd. However the functions above work
250 for both session and system services.
251
252 See sd_booted(3) for more information.
253 */
254 int sd_booted(void) _sd_hidden_;
255
256 #ifdef __cplusplus
257 }
258 #endif
259
260 #endif
00 #!/usr/bin/env bash
11
2 . "$SRCDIR/sh-tests/common.functions"
2 . sh-tests/common.functions
33
44 server=localhost
55 tmpdir="$TMPDIR"
77 test -z "$tmpdir" && tmpdir=/tmp
88 out1="${tmpdir}/bnch$$.1"
99 logdir="${tmpdir}/bnch$$.d"
10 nc="$SRCDIR/sh-tests/netcat.py"
10 nc=sh-tests/netcat.py
1111
1212 cleanup() {
1313 killbeanstalkd
00 #!/usr/bin/env bash
11
2 . "$SRCDIR/sh-tests/common.functions"
2 . sh-tests/common.functions
33
44 server=localhost
55 tmpdir="$TMPDIR"
77 out1="${tmpdir}/bnch$$.1"
88 out2="${tmpdir}/bnch$$.2"
99 logdir="${tmpdir}/bnch$$.d"
10 nc="$SRCDIR/sh-tests/netcat.py"
10 nc=sh-tests/netcat.py
1111
1212 cleanup() {
1313 killbeanstalkd
00 #!/usr/bin/env bash
11
2 . "$SRCDIR/sh-tests/common.functions"
2 . "sh-tests/common.functions"
33
44 server=localhost
55 tmpdir="$TMPDIR"
77 out1="${tmpdir}/bnch$$.1"
88 out2="${tmpdir}/bnch$$.2"
99 logdir="${tmpdir}/bnch$$.d"
10 nc="$SRCDIR/sh-tests/netcat.py"
10 nc="sh-tests/netcat.py"
1111
1212 cleanup() {
1313 killbeanstalkd
00 #!/usr/bin/env bash
11
2 . "$SRCDIR/sh-tests/common.functions"
2 . "sh-tests/common.functions"
33
44 ENOSPC=28
55 server=localhost
99 out1="${tmpdir}/bnch$$.1"
1010 out2="${tmpdir}/bnch$$.2"
1111 logdir="${tmpdir}/bnch$$.d"
12 nc="$SRCDIR/sh-tests/netcat.py"
12 nc="sh-tests/netcat.py"
1313
1414 if test "`type -t fiu-run`" = ''
1515 then
00 #!/usr/bin/env bash
11
2 . "$SRCDIR/sh-tests/common.functions"
2 . "sh-tests/common.functions"
33
44 ENOSPC=28
55 server=localhost
99 out1="${tmpdir}/bnch$$.1"
1010 out2="${tmpdir}/bnch$$.2"
1111 logdir="${tmpdir}/bnch$$.d"
12 nc="$SRCDIR/sh-tests/netcat.py"
12 nc="sh-tests/netcat.py"
1313
1414 if test "`type -t fiu-run`" = ''
1515 then
0 #!/usr/bin/env bash
1
2 . "sh-tests/common.functions"
3
4 server=localhost
5 tmpdir="$TMPDIR"
6 size=601
7 test -z "$tmpdir" && tmpdir=/tmp
8 out1="${tmpdir}/bnch$$.1"
9 logdir="${tmpdir}/bnch$$.d"
10 nc="sh-tests/netcat.py"
11
12 cleanup() {
13 killbeanstalkd
14 rm -rf "$logdir" "$out1"
15 }
16
17 catch() {
18 echo '' Interrupted
19 exit 3
20 }
21
22 trap cleanup EXIT
23 trap catch HUP INT QUIT TERM
24
25 if [ ! -x ./beanstalkd ]; then
26 echo "Executable ./beanstalkd not found; do you need to compile first?"
27 exit 2
28 fi
29
30 start_beanstalkd $logdir
31
32 killbeanstalkd # uses -9, which we need here
33
34 start_beanstalkd $logdir
35
36 $nc $server $port <<EOF > "$out1"
37 put 0 0 0 0
38
39 quit
40 EOF
41
42 diff - "$out1" <<EOF
43 INSERTED 1
44 EOF
45
00 #!/usr/bin/env bash
11
2 . "$SRCDIR/sh-tests/common.functions"
2 . "sh-tests/common.functions"
33
44 server=localhost
55 tmpdir="$TMPDIR"
77 out1="${tmpdir}/bnch$$.1"
88 out2="${tmpdir}/bnch$$.2"
99 logdir="${tmpdir}/bnch$$.d"
10 nc="$SRCDIR/sh-tests/netcat.py"
10 nc="sh-tests/netcat.py"
1111
1212 cleanup() {
1313 killbeanstalkd
00 #!/usr/bin/env bash
11
2 . "$SRCDIR/sh-tests/common.functions"
2 . "sh-tests/common.functions"
33
44 server=localhost
55 tmpdir="$TMPDIR"
88 out1="${tmpdir}/bnch$$.1"
99 out2="${tmpdir}/bnch$$.2"
1010 logdir="${tmpdir}/bnch$$.d"
11 nc="$SRCDIR/sh-tests/netcat.py"
11 nc="sh-tests/netcat.py"
1212
1313 fail() {
1414 printf 'On line '
0 #!/usr/bin/env bash
1
2 . "sh-tests/common.functions"
3
4 server=localhost
5 tmpdir="$TMPDIR"
6 test -z "$tmpdir" && tmpdir=/tmp
7 out1="${tmpdir}/bnch$$.1"
8 out2="${tmpdir}/bnch$$.2"
9 logdir="${tmpdir}/bnch$$.d"
10 nc="sh-tests/netcat.py"
11
12 cleanup() {
13 killbeanstalkd
14 rm -rf "$logdir" "$out1" "$out2"
15 }
16
17 catch() {
18 echo '' Interrupted
19 exit 3
20 }
21
22 trap cleanup EXIT
23 trap catch HUP INT QUIT TERM
24
25 if [ ! -x ./beanstalkd ]; then
26 echo "Executable ./beanstalkd not found; do you need to compile first?"
27 exit 2
28 fi
29
30 if ! type beanstalkd-1.4.6 >/dev/null
31 then echo beanstalkd 1.4.6 not found -- skipping binlog-v5. ; exit 0
32 fi
33 start_beanstalkd $logdir '' '' beanstalkd-1.4.6
34
35 $nc $server $port <<EOF |egrep -v "age|time-left" >"$out1"
36 use test
37 put 1 2 3 4
38 test
39 put 4 3 2 1
40 x
41 stats-job 1
42 stats-job 2
43 quit
44 EOF
45
46 diff - "$out1" <<EOF
47 USING test
48 INSERTED 1
49 INSERTED 2
50 OK 134
51 ---
52 id: 1
53 tube: test
54 state: delayed
55 pri: 1
56 delay: 2
57 ttr: 3
58 reserves: 0
59 timeouts: 0
60 releases: 0
61 buries: 0
62 kicks: 0
63
64 OK 134
65 ---
66 id: 2
67 tube: test
68 state: delayed
69 pri: 4
70 delay: 3
71 ttr: 2
72 reserves: 0
73 timeouts: 0
74 releases: 0
75 buries: 0
76 kicks: 0
77
78 EOF
79 res=$?
80 test "$res" -eq 0 || exit $res
81
82 killbeanstalkd
83
84 sleep 1
85 start_beanstalkd $logdir
86
87 $nc $server $port <<EOF |egrep -v "age|time-left" >"$out2"
88 stats-job 1
89 stats-job 2
90 quit
91 EOF
92
93 diff - "$out2" <<EOF
94 OK 142
95 ---
96 id: 1
97 tube: test
98 state: delayed
99 pri: 1
100 delay: 2
101 ttr: 3
102 file: 1
103 reserves: 0
104 timeouts: 0
105 releases: 0
106 buries: 0
107 kicks: 0
108
109 OK 142
110 ---
111 id: 2
112 tube: test
113 state: delayed
114 pri: 4
115 delay: 3
116 ttr: 2
117 file: 1
118 reserves: 0
119 timeouts: 0
120 releases: 0
121 buries: 0
122 kicks: 0
123
124 EOF
125
1414 logdir="$1"
1515 other_args="$2" # other_args and fiu are optional
1616 fiu="$3"
17 cmd=$4 # optional
1718
1819 if [ "x$logdir" != "x" ]; then
1920 mkdir -p $logdir
2021 other_args="-b $logdir $other_args"
2122 fi
2223
24 if test "$cmd" = ""
25 then cmd=./beanstalkd
26 fi
27
2328 max_port=$(($port + $max_port_retries))
2429 while [ $port -lt $max_port ]; do
2530 if test "$VERBOSE"
2631 then
27 echo "$fiu ./beanstalkd -l 127.0.0.1 -p $port $other_args &"
28 $fiu ./beanstalkd -l 127.0.0.1 -p $port $other_args &
32 echo "$fiu $cmd -l 127.0.0.1 -p $port $other_args &"
33 $fiu $cmd -l 127.0.0.1 -p $port $other_args &
2934 else
30 $fiu ./beanstalkd -l 127.0.0.1 -p $port $other_args >/dev/null 2>/dev/null &
35 $fiu $cmd -l 127.0.0.1 -p $port $other_args >/dev/null 2>/dev/null &
3136 fi
3237 bpid=$!
3338
0 # Negative delays are illegal
10 put 512 -1 100 0
21 quit
00 INSERTED 1
1 OK 135
1 OK 143
22 ---
33 id: 1
44 tube: default
88 delay: 0
99 ttr: 5
1010 time-left: 0
11 file: 0
1112 reserves: 0
1213 timeouts: 0
1314 releases: 0
00 INSERTED 1
11 INSERTED 2
2 OK 251
2 OK 265
33 ---
44 name: default
55 current-jobs-urgent: 0
1111 current-using: 1
1212 current-watching: 1
1313 current-waiting: 0
14 cmd-delete: 0
1415 cmd-pause-tube: 0
1516 pause: 0
1617 pause-time-left: 0
1718
1819 PAUSED
19 OK 252
20 OK 266
2021 ---
2122 name: default
2223 current-jobs-urgent: 0
2829 current-using: 1
2930 current-watching: 1
3031 current-waiting: 0
32 cmd-delete: 0
3133 cmd-pause-tube: 1
3234 pause: 10
3335 pause-time-left: 9
3739 1
3840 DELETED
3941 PAUSED
40 OK 251
42 OK 265
4143 ---
4244 name: default
4345 current-jobs-urgent: 1
4951 current-using: 1
5052 current-watching: 1
5153 current-waiting: 0
54 cmd-delete: 1
5255 cmd-pause-tube: 3
5356 pause: 3
5457 pause-time-left: 2
5558
56 OK 135
59 OK 143
5760 ---
5861 id: 2
5962 tube: default
6366 delay: 1
6467 ttr: 1
6568 time-left: 0
69 file: 0
6670 reserves: 0
6771 timeouts: 0
6872 releases: 0
7175
7276 RESERVED 2 1
7377 2
74 OK 138
78 OK 146
7579 ---
7680 id: 2
7781 tube: default
8185 delay: 1
8286 ttr: 1
8387 time-left: 0
88 file: 0
8489 reserves: 1
8590 timeouts: 0
8691 releases: 0
0 use tubea
1 put 0 0 0 0
2
3 delete 1
4 stats-tube tubea
5 stats-tube default
6 quit
0 USING tubea
1 INSERTED 1
2 DELETED
3 OK 263
4 ---
5 name: tubea
6 current-jobs-urgent: 0
7 current-jobs-ready: 0
8 current-jobs-reserved: 0
9 current-jobs-delayed: 0
10 current-jobs-buried: 0
11 total-jobs: 1
12 current-using: 1
13 current-watching: 0
14 current-waiting: 0
15 cmd-delete: 1
16 cmd-pause-tube: 0
17 pause: 0
18 pause-time-left: 0
19
20 OK 265
21 ---
22 name: default
23 current-jobs-urgent: 0
24 current-jobs-ready: 0
25 current-jobs-reserved: 0
26 current-jobs-delayed: 0
27 current-jobs-buried: 0
28 total-jobs: 0
29 current-using: 0
30 current-watching: 1
31 current-waiting: 0
32 cmd-delete: 0
33 cmd-pause-tube: 0
34 pause: 0
35 pause-time-left: 0
36
44 INSERTED 5
55 INSERTED 6
66 INSERTED 7
7 OK 137
7 OK 145
88 ---
99 id: 1
1010 tube: default
1414 delay: 0
1515 ttr: 120
1616 time-left: 0
17 file: 0
1718 reserves: 0
1819 timeouts: 0
1920 releases: 0
2021 buries: 0
2122 kicks: 0
2223
23 OK 138
24 OK 146
2425 ---
2526 id: 2
2627 tube: default
3031 delay: 0
3132 ttr: 4294
3233 time-left: 0
34 file: 0
3335 reserves: 0
3436 timeouts: 0
3537 releases: 0
3638 buries: 0
3739 kicks: 0
3840
39 OK 138
41 OK 146
4042 ---
4143 id: 3
4244 tube: default
4648 delay: 0
4749 ttr: 4295
4850 time-left: 0
51 file: 0
4952 reserves: 0
5053 timeouts: 0
5154 releases: 0
5255 buries: 0
5356 kicks: 0
5457
55 OK 138
58 OK 146
5659 ---
5760 id: 4
5861 tube: default
6265 delay: 0
6366 ttr: 4296
6467 time-left: 0
68 file: 0
6569 reserves: 0
6670 timeouts: 0
6771 releases: 0
6872 buries: 0
6973 kicks: 0
7074
71 OK 138
75 OK 146
7276 ---
7377 id: 5
7478 tube: default
7882 delay: 0
7983 ttr: 4297
8084 time-left: 0
85 file: 0
8186 reserves: 0
8287 timeouts: 0
8388 releases: 0
8489 buries: 0
8590 kicks: 0
8691
87 OK 138
92 OK 146
8893 ---
8994 id: 6
9095 tube: default
9499 delay: 0
95100 ttr: 5000
96101 time-left: 0
102 file: 0
97103 reserves: 0
98104 timeouts: 0
99105 releases: 0
100106 buries: 0
101107 kicks: 0
102108
103 OK 139
109 OK 147
104110 ---
105111 id: 7
106112 tube: default
110116 delay: 0
111117 ttr: 21600
112118 time-left: 0
119 file: 0
113120 reserves: 0
114121 timeouts: 0
115122 releases: 0
0 put 0 0 0 1
1 a
2 stats-job 1
3 quit
0 INSERTED 1
1 OK 143
2 ---
3 id: 1
4 tube: default
5 state: ready
6 pri: 0
7 age: 0
8 delay: 0
9 ttr: 1
10 time-left: 0
11 file: 0
12 reserves: 0
13 timeouts: 0
14 releases: 0
15 buries: 0
16 kicks: 0
17
0 #include <stdlib.h>
1 #include <errno.h>
2 #include <sys/types.h>
3 #include <sys/event.h>
4 #include <sys/time.h>
5 #include "dat.h"
6
7 enum
8 {
9 Infinity = 1 << 30
10 };
11
12 static void handle(Socket*, int, int);
13
14 static Handle tick;
15 static void *tickval;
16 static int kq;
17 static int64 ival;
18 static struct timespec ivalts;
19
20
21 void
22 sockinit(Handle f, void *x, int64 ns)
23 {
24 tick = f;
25 tickval = x;
26 ival = ns;
27 ivalts.tv_sec = ns / 1000000000;
28 ivalts.tv_nsec = ns % 1000000000;
29 kq = kqueue();
30 if (kq == -1) {
31 twarn("kqueue");
32 exit(1);
33 }
34 }
35
36
37 int
38 sockwant(Socket *s, int rw)
39 {
40 struct kevent ev = {};
41 struct timespec ts = {};
42
43 if (!s->added && !rw) {
44 return 0;
45 } else if (rw) {
46 s->added = 1;
47 ev.flags = EV_ADD;
48 } else {
49 ev.flags = EV_DELETE;
50 }
51
52 switch (rw) {
53 case 'r':
54 ev.filter = EVFILT_READ;
55 break;
56 case 'w':
57 ev.filter = EVFILT_WRITE;
58 break;
59 default:
60 // check only for hangup
61 ev.filter = EVFILT_READ;
62 ev.fflags = NOTE_LOWAT;
63 ev.data = Infinity;
64 }
65 ev.ident = s->fd;
66 ev.udata = s;
67 return kevent(kq, &ev, 1, NULL, 0, &ts);
68 }
69
70
71 void
72 sockmain()
73 {
74 int i, r, n = 1;
75 int64 e, t = nanoseconds();
76 struct kevent evs[n];
77
78 for (;;) {
79 r = kevent(kq, NULL, 0, evs, n, &ivalts);
80 if (r == -1 && errno != EINTR) {
81 twarn("kevent");
82 exit(1);
83 }
84
85 // should tick?
86 e = nanoseconds();
87 if (e-t > ival) {
88 tick(tickval, 0);
89 t = e;
90 }
91
92 for (i=0; i<r; i++) {
93 handle(evs[i].udata, evs[i].filter, evs[i].flags);
94 }
95
96 }
97 }
98
99
100 static void
101 handle(Socket *s, int filt, int flags)
102 {
103 if (flags & EV_EOF) {
104 s->f(s->x, 'h');
105 } else if (filt == EVFILT_READ) {
106 s->f(s->x, 'r');
107 } else if (filt == EVFILT_WRITE) {
108 s->f(s->x, 'w');
109 }
110 }
0 #include "sock-bsd.c"
0 #include "sock-bsd.c"
0 #include <stdlib.h>
1 #include <errno.h>
2 #include <sys/epoll.h>
3 #include "dat.h"
4
5 static void handle(Socket *s, int events);
6
7 static Handle tick;
8 static void *tickval;
9 static int epfd;
10 static int ival; // ms
11
12
13 void
14 sockinit(Handle f, void *x, int64 ns)
15 {
16 tick = f;
17 tickval = x;
18 ival = ns / 1000000;
19 epfd = epoll_create1(0);
20 if (epfd == -1) {
21 twarn("epoll_create");
22 exit(1);
23 }
24 }
25
26
27 int
28 sockwant(Socket *s, int rw)
29 {
30 int op;
31 struct epoll_event ev = {};
32
33 if (!s->added && !rw) {
34 return 0;
35 } else if (!s->added && rw) {
36 s->added = 1;
37 op = EPOLL_CTL_ADD;
38 } else if (!rw) {
39 op = EPOLL_CTL_DEL;
40 } else {
41 op = EPOLL_CTL_MOD;
42 }
43
44 switch (rw) {
45 case 'r':
46 ev.events = EPOLLIN;
47 break;
48 case 'w':
49 ev.events = EPOLLOUT;
50 break;
51 }
52 ev.events |= EPOLLRDHUP | EPOLLPRI;
53 ev.data.ptr = s;
54
55 return epoll_ctl(epfd, op, s->fd, &ev);
56 }
57
58
59 void
60 sockmain()
61 {
62 int i, r, n = 1;
63 int64 e, t = nanoseconds();
64 struct epoll_event evs[n];
65
66 for (;;) {
67 r = epoll_wait(epfd, evs, n, ival);
68 if (r == -1 && errno != EINTR) {
69 twarn("epoll_wait");
70 exit(1);
71 }
72
73 // should tick?
74 e = nanoseconds();
75 if ((e-t) / 1000000 > ival) {
76 tick(tickval, 0);
77 t = e;
78 }
79
80 for (i=0; i<r; i++) {
81 handle(evs[i].data.ptr, evs[i].events);
82 }
83
84 }
85 }
86
87
88 static void
89 handle(Socket *s, int evset)
90 {
91 int c = 0;
92
93 if (evset & (EPOLLHUP|EPOLLRDHUP)) {
94 c = 'h';
95 } else if (evset & EPOLLIN) {
96 c = 'r';
97 } else if (evset & EPOLLOUT) {
98 c = 'w';
99 }
100
101 s->f(s->x, c);
102 }
0 #include <stdint.h>
1 #include <stdlib.h>
2 #include <sys/socket.h>
3 #include "dat.h"
4
5
6 void
7 srv(Srv *s)
8 {
9 int r;
10
11 sockinit((Handle)srvtick, s, 10*1000000); // 10ms
12
13 s->sock.x = s;
14 s->sock.f = (Handle)srvaccept;
15 s->conns.less = (Less)connless;
16 s->conns.rec = (Record)connrec;
17
18 r = listen(s->sock.fd, 1024);
19 if (r == -1) {
20 twarn("listen");
21 return;
22 }
23
24 r = sockwant(&s->sock, 'r');
25 if (r == -1) {
26 twarn("sockwant");
27 exit(2);
28 }
29
30 sockmain();
31 twarnx("sockmain");
32 exit(1);
33 }
34
35
36 void
37 srvschedconn(Srv *s, conn c)
38 {
39 if (c->tickpos > -1) {
40 heapremove(&s->conns, c->tickpos);
41 }
42 if (c->tickat) {
43 heapinsert(&s->conns, c);
44 }
45 }
46
47
48 void
49 srvaccept(Srv *s, int ev)
50 {
51 h_accept(s->sock.fd, ev, s);
52 }
53
54
55 void
56 srvtick(Srv *s, int ev)
57 {
58 prottick(s);
59 }
+0
-37
stat.h less more
0 /* stat.h - stats struct */
1
2 /* Copyright (C) 2008 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef stat_h
19 #define stat_h
20
21 #include "config.h"
22
23 #if HAVE_STDINT_H
24 # include <stdint.h>
25 #endif /* else we get int types from config.h */
26
27 struct stats {
28 unsigned int urgent_ct;
29 unsigned int waiting_ct;
30 unsigned int buried_ct;
31 unsigned int reserved_ct;
32 unsigned int pause_ct;
33 uint64_t total_jobs_ct;
34 };
35
36 #endif /*stat_h*/
+0
-118
tests/test_job.c less more
0 #include <stdlib.h>
1 #include <stdio.h>
2
3 #include "../cut.h"
4 #include "../tube.h"
5 #include "../job.h"
6 #include "../util.h"
7 #include "../pq.h"
8
9 static tube default_tube;
10
11 void
12 __CUT_BRINGUP__job()
13 {
14 job_init();
15 TUBE_ASSIGN(default_tube, make_tube("default"));
16 }
17
18 void
19 __CUT__job_test_creation()
20 {
21 job j;
22
23 j = make_job(1, 0, 1, 0, default_tube);
24 ASSERT(j->pri == 1, "priority should match");
25 }
26
27 void
28 __CUT__job_test_cmp_pris()
29 {
30 job a, b;
31
32 a = make_job(1, 0, 1, 0, default_tube);
33 b = make_job(1 << 27, 0, 1, 0, default_tube);
34
35 ASSERT(job_pri_cmp(a, b) < 0, "should be a < b");
36 }
37
38 void
39 __CUT__job_test_cmp_ids()
40 {
41 job a, b;
42
43 a = make_job(1, 0, 1, 0, default_tube);
44 b = make_job(1, 0, 1, 0, default_tube);
45
46 b->id <<= 49;
47 ASSERT(job_pri_cmp(a, b) < 0, "should be a < b");
48 }
49
50
51 void
52 __CUT__job_test_large_pris()
53 {
54 job a, b;
55
56 a = make_job(1, 0, 1, 0, default_tube);
57 b = make_job(-5, 0, 1, 0, default_tube);
58
59 ASSERT(job_pri_cmp(a, b) < 0, "should be a < b");
60
61 a = make_job(-5, 0, 1, 0, default_tube);
62 b = make_job(1, 0, 1, 0, default_tube);
63
64 ASSERT(job_pri_cmp(a, b) > 0, "should be a > b");
65 }
66
67 void
68 __CUT__job_test_hash_free()
69 {
70 job j;
71 uint64_t jid = 83;
72
73 j = make_job_with_id(0, 0, 1, 0, default_tube, jid);
74 job_free(j);
75
76 ASSERT(!job_find(jid), "job should be missing");
77 }
78
79 void
80 __CUT__job_test_hash_free_next()
81 {
82 job a, b;
83 uint64_t aid = 97, bid = 12386;
84
85 b = make_job_with_id(0, 0, 1, 0, default_tube, bid);
86 a = make_job_with_id(0, 0, 1, 0, default_tube, aid);
87
88 ASSERT(a->ht_next == b, "b should be chained to a");
89
90 job_free(b);
91
92 ASSERT(a->ht_next == NULL, "job should be missing");
93 }
94
95 void
96 __CUT__job_test_all_jobs_used()
97 {
98 job j, x;
99
100 j = make_job(0, 0, 1, 0, default_tube);
101 ASSERT(get_all_jobs_used() == 1, "should match");
102
103 x = allocate_job(10);
104 ASSERT(get_all_jobs_used() == 1, "should match");
105
106 job_free(x);
107 ASSERT(get_all_jobs_used() == 1, "should match");
108
109 job_free(j);
110 ASSERT(get_all_jobs_used() == 0, "should match");
111 }
112
113 void
114 __CUT_TAKEDOWN__job()
115 {
116 }
117
+0
-139
tests/test_pq.c less more
0 #include <stdlib.h>
1 #include <stdio.h>
2
3 #include "../cut.h"
4 #include "../tube.h" /* hack to make cpp happy */
5 #include "../pq.h"
6
7 static struct pq qq;
8 static pq q = &qq;
9 static job j1, j2, j3a, j3b, j3c;
10 static tube default_tube;
11
12 void
13 __CUT_BRINGUP__pq()
14 {
15 job_init();
16 TUBE_ASSIGN(default_tube, make_tube("default"));
17 pq_init(q, job_pri_cmp);
18 j1 = make_job(1, 0, 1, 0, default_tube);
19 j2 = make_job(2, 0, 1, 0, default_tube);
20 j3a = make_job(3, 0, 1, 0, default_tube);
21 j3b = make_job(3, 0, 1, 0, default_tube);
22 j3c = make_job(3, 0, 1, 0, default_tube);
23 ASSERT(!!j1, "Allocation should work");
24 ASSERT(!!j2, "Allocation should work");
25 ASSERT(!!j3a, "Allocation should work");
26 ASSERT(!!j3b, "Allocation should work");
27 ASSERT(!!j3c, "Allocation should work");
28 }
29
30 void
31 __CUT__pq_test_empty_queue_should_have_no_items()
32 {
33 ASSERT(q->used == 0, "q should be empty.");
34 }
35
36 void
37 __CUT__pq_test_insert_one()
38 {
39 pq_give(q, j1);
40 ASSERT(q->used == 1, "q should contain one item.");
41 }
42
43 void
44 __CUT__pq_test_insert_and_remove_one()
45 {
46 int r;
47 job j;
48
49 r = pq_give(q, j1);
50 ASSERT(r, "insert should succeed");
51
52 j = pq_take(q);
53 ASSERT(j == j1, "j1 should come back out");
54 ASSERT(q->used == 0, "q should be empty.");
55 }
56
57 void
58 __CUT__pq_test_priority()
59 {
60 int r;
61 job j;
62
63 r = pq_give(q, j2);
64 ASSERT(r, "insert should succeed");
65
66 r = pq_give(q, j3a);
67 ASSERT(r, "insert should succeed");
68
69 r = pq_give(q, j1);
70 ASSERT(r, "insert should succeed");
71
72 j = pq_take(q);
73 ASSERT(j == j1, "j1 should come out first.");
74
75 j = pq_take(q);
76 ASSERT(j == j2, "j2 should come out second.");
77
78 j = pq_take(q);
79 ASSERT(j == j3a, "j3a should come out third.");
80 }
81
82 void
83 __CUT__pq_test_fifo_property()
84 {
85 int r;
86 job j;
87
88 r = pq_give(q, j3a);
89 ASSERT(r, "insert should succeed");
90 ASSERT(q->heap[0] == j3a, "j3a should be in pos 0");
91
92 r = pq_give(q, j3b);
93 ASSERT(r, "insert should succeed");
94 ASSERT(q->heap[1] == j3b, "j3b should be in pos 1");
95
96 r = pq_give(q, j3c);
97 ASSERT(r, "insert should succeed");
98 ASSERT(q->heap[2] == j3c, "j3c should be in pos 2");
99
100 j = pq_take(q);
101 ASSERT(j == j3a, "j3a should come out first.");
102
103 j = pq_take(q);
104 ASSERT(j == j3b, "j3b should come out second.");
105
106 j = pq_take(q);
107 ASSERT(j == j3c, "j3c should come out third.");
108 }
109
110 #define HOW_MANY 20
111 void
112 __CUT__pq_test_many_jobs()
113 {
114 unsigned int last_pri;
115 int r, i;
116 job j;
117
118 for (i = 0; i < HOW_MANY; i++) {
119 j = make_job(1 + rand() % 8192, 0, 1, 0, default_tube);
120 ASSERT(!!j, "allocation");
121 r = pq_give(q, j);
122 ASSERT(r, "insert should succeed");
123 }
124
125 last_pri = 0;
126 for (i = 0; i < HOW_MANY; i++) {
127 j = pq_take(q);
128 /*printf("j->pri=%d last_pri=%d\n", j->pri, last_pri);*/
129 ASSERT(j->pri >= last_pri, "should come out in order.");
130 last_pri = j->pri;
131 }
132 }
133
134 void
135 __CUT_TAKEDOWN__pq()
136 {
137 }
138
0 #include <stdint.h>
1 #include <stdlib.h>
2 #include <sys/time.h>
3 #include "dat.h"
4
5 int64
6 nanoseconds(void)
7 {
8 int r;
9 struct timeval tv;
10
11 r = gettimeofday(&tv, 0);
12 if (r != 0) return warnx("gettimeofday"), -1; // can't happen
13
14 return ((int64)tv.tv_sec)*1000000000 + ((int64)tv.tv_usec)*1000;
15 }
0 /* tube.c - tubes implementation */
1
2 /* Copyright (C) 2008 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
0 #include <stdint.h>
181 #include <stdlib.h>
192 #include <string.h>
20
21 #include "ms.h"
22 #include "stat.h"
23 #include "tube.h"
24 #include "prot.h"
25 #include "util.h"
3 #include "dat.h"
264
275 struct ms tubes;
286
319 {
3210 tube t;
3311
34 t = malloc(sizeof(struct tube));
12 t = new(struct tube);
3513 if (!t) return NULL;
36
37 t->refs = 0;
3814
3915 t->name[MAX_TUBE_NAME_LEN - 1] = '\0';
4016 strncpy(t->name, name, MAX_TUBE_NAME_LEN - 1);
4117 if (t->name[MAX_TUBE_NAME_LEN - 1] != '\0') twarnx("truncating tube name");
4218
43 pq_init(&t->ready, job_pri_cmp);
44 pq_init(&t->delay, job_delay_cmp);
19 t->ready.less = job_pri_less;
20 t->delay.less = job_delay_less;
21 t->ready.rec = job_setheappos;
22 t->delay.rec = job_setheappos;
4523 t->buried = (struct job) { };
4624 t->buried.prev = t->buried.next = &t->buried;
4725 ms_init(&t->waiting, NULL, NULL);
48
49 t->stat = (struct stats) {0, 0, 0, 0, 0};
50 t->using_ct = t->watching_ct = 0;
51 t->deadline_at = t->pause = 0;
5226
5327 return t;
5428 }
5731 tube_free(tube t)
5832 {
5933 prot_remove_tube(t);
60 pq_clear(&t->ready);
61 pq_clear(&t->delay);
34 free(t->ready.data);
35 free(t->delay.data);
6236 ms_clear(&t->waiting);
6337 free(t);
6438 }
+0
-56
tube.h less more
0 /* tube.h - tubes header */
1
2 /* Copyright (C) 2008 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef tube_h
19 #define tube_h
20
21 typedef struct tube *tube;
22
23 typedef void(*evh)(int, short, void *);
24
25 #include "stat.h"
26 #include "job.h"
27 #include "pq.h"
28 #include "ms.h"
29
30 #define MAX_TUBE_NAME_LEN 201
31
32 struct tube {
33 unsigned int refs;
34 char name[MAX_TUBE_NAME_LEN];
35 struct pq ready;
36 struct pq delay;
37 struct job buried;
38 struct ms waiting; /* set of conns */
39 struct stats stat;
40 unsigned int using_ct;
41 unsigned int watching_ct;
42 usec pause;
43 usec deadline_at;
44 };
45
46 extern struct ms tubes;
47
48 tube make_tube(const char *name);
49 void tube_dref(tube t);
50 void tube_iref(tube t);
51 tube tube_find(const char *name);
52 tube tube_find_or_make(const char *name);
53 #define TUBE_ASSIGN(a,b) (tube_dref(a), (a) = (b), tube_iref(a))
54
55 #endif /*tube_h*/
0 #include <stdint.h>
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <sys/time.h>
5 #include "ct/ct.h"
6 #include "dat.h"
7
8 void
9 cttestallocf()
10 {
11 char *got;
12
13 got = fmtalloc("hello, %s %d", "world", 5);
14 assertf(strcmp("hello, world 5", got) == 0, "got \"%s\"", got);
15 }
0 /* util.c - util functions */
1
2 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
0 #include <stdint.h>
1 #include <stdlib.h>
182 #include <errno.h>
19 #include <stdarg.h>
203 #include <stdio.h>
214 #include <string.h>
22 #include <unistd.h>
23 #include <sys/time.h>
5 #include <stdarg.h>
6 #include "dat.h"
247
25 #include "util.h"
26
27 char *progname; /* defined as extern in util.h */
8 const char *progname;
289
2910 void
3011 v()
3718 fprintf(stderr, "%s: ", progname);
3819 if (fmt) {
3920 vfprintf(stderr, fmt, args);
40 if (err) fprintf(stderr, ": %s", strerror(errno));
21 if (err) fprintf(stderr, ": %s", err);
4122 }
4223 fputc('\n', stderr);
4324 }
4526 void
4627 warn(const char *fmt, ...)
4728 {
29 char *err = strerror(errno); /* must be done first thing */
4830 va_list args;
31
4932 va_start(args, fmt);
50 vwarnx(strerror(errno), fmt, args);
33 vwarnx(err, fmt, args);
5134 va_end(args);
5235 }
5336
6043 va_end(args);
6144 }
6245
63 usec
64 usec_from_timeval(struct timeval *tv)
46
47 char*
48 fmtalloc(char *fmt, ...)
6549 {
66 return ((usec) tv->tv_sec) * SECOND + tv->tv_usec;
50 int n;
51 char *buf;
52 va_list ap;
53
54 // find out how much space is needed
55 va_start(ap, fmt);
56 n = vsnprintf(0, 0, fmt, ap) + 1; // include space for trailing NUL
57 va_end(ap);
58
59 buf = malloc(n);
60 if (buf) {
61 va_start(ap, fmt);
62 vsnprintf(buf, n, fmt, ap);
63 va_end(ap);
64 }
65 return buf;
6766 }
6867
69 void
70 timeval_from_usec(struct timeval *tv, usec t)
68
69 // Zalloc allocates n bytes of zeroed memory and
70 // returns a pointer to it.
71 // If insufficient memory is available, zalloc returns 0.
72 void*
73 zalloc(int n)
7174 {
72 tv->tv_sec = t / SECOND;
73 tv->tv_usec = t % SECOND;
75 void *p;
76
77 p = malloc(n);
78 if (p) {
79 memset(p, 0, n);
80 }
81 return p;
7482 }
75
76 usec
77 now_usec(void)
78 {
79 int r;
80 struct timeval tv;
81
82 r = gettimeofday(&tv, 0);
83 if (r != 0) return warnx("gettimeofday"), -1; // can't happen
84
85 return usec_from_timeval(&tv);
86 }
87
+0
-60
util.h less more
0 /* util.h - util functions */
1
2 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
3
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef util_h
19 #define util_h
20
21 #include "config.h"
22
23 #if HAVE_STDINT_H
24 # include <stdint.h>
25 #endif /* else we get int types from config.h */
26
27 #include <stdlib.h>
28 #include <sys/time.h>
29
30 #define min(a,b) ((a)<(b)?(a):(b))
31
32 void v();
33
34 void warn(const char *fmt, ...);
35 void warnx(const char *fmt, ...);
36
37 extern char *progname;
38
39 #define twarn(fmt, args...) warn("%s:%d in %s: " fmt, \
40 __FILE__, __LINE__, __func__, ##args)
41 #define twarnx(fmt, args...) warnx("%s:%d in %s: " fmt, \
42 __FILE__, __LINE__, __func__, ##args)
43
44 #ifdef DEBUG
45 #define dprintf(fmt, args...) ((void) fprintf(stderr, fmt, ##args))
46 #else
47 #define dprintf(fmt, ...) ((void) 0)
48 #endif
49
50 typedef uint64_t usec;
51 #define USEC (1)
52 #define MSEC (1000 * USEC)
53 #define SECOND (1000 * MSEC)
54
55 usec now_usec(void);
56 usec usec_from_timeval(struct timeval *tv);
57 void timeval_from_usec(struct timeval *tv, usec t);
58
59 #endif /*util_h*/
+0
-4
version.sh less more
0 #!/bin/sh
1
2 # This file was generated by "make dist".
3 echo 1.4.6
0 #include <stdint.h>
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <fcntl.h>
4 #include <unistd.h>
5 #include <string.h>
6 #include <errno.h>
7 #include <dirent.h>
8 #include <sys/uio.h>
9 #include <sys/stat.h>
10 #include <limits.h>
11 #include "dat.h"
12
13 static int reserve(Wal *w, int n);
14
15
16 // Reads w->dir for files matching binlog.NNN,
17 // sets w->next to the next unused number, and
18 // returns the minimum number.
19 // If no files are found, sets w->next to 1 and
20 // returns a large number.
21 static int
22 walscandir(Wal *w)
23 {
24 static char base[] = "binlog.";
25 static const int len = sizeof(base) - 1;
26 DIR *d;
27 struct dirent *e;
28 int min = 1<<30;
29 int max = 0;
30 int n;
31 char *p;
32
33 d = opendir(w->dir);
34 if (!d) return min;
35
36 while ((e = readdir(d))) {
37 if (strncmp(e->d_name, base, len) == 0) {
38 n = strtol(e->d_name+len, &p, 10);
39 if (p && *p == '\0') {
40 if (n > max) max = n;
41 if (n < min) min = n;
42 }
43 }
44 }
45
46 closedir(d);
47 w->next = max + 1;
48 return min;
49 }
50
51
52 void
53 walgc(Wal *w)
54 {
55 File *f;
56
57 while (w->head && !w->head->refs) {
58 f = w->head;
59 w->head = f->next;
60 if (w->tail == f) {
61 w->tail = f->next; // also, f->next == NULL
62 }
63
64 w->nfile--;
65 unlink(f->path);
66 free(f->path);
67 free(f);
68 }
69 }
70
71
72 // returns 1 on success, 0 on error.
73 static int
74 usenext(Wal *w)
75 {
76 File *f;
77
78 f = w->cur;
79 if (!f->next) {
80 twarnx("there is no next wal file");
81 return 0;
82 }
83
84 w->cur = f->next;
85 filewclose(f);
86 return 1;
87 }
88
89
90 static int
91 ratio(Wal *w)
92 {
93 int n, d;
94
95 d = w->alive + w->resv;
96 n = w->nfile*w->filesz - d;
97 if (!d) return 0;
98 return n / d;
99 }
100
101
102 // Returns the number of bytes reserved or 0 on error.
103 static int
104 walresvmigrate(Wal *w, job j)
105 {
106 int z = 0;
107
108 // reserve only space for the migrated full job record
109 // space for the delete is already reserved
110 z += sizeof(int);
111 z += strlen(j->tube->name);
112 z += sizeof(Jobrec);
113 z += j->r.body_size;
114
115 return reserve(w, z);
116 }
117
118
119 static void
120 moveone(Wal *w)
121 {
122 job j;
123
124 if (w->head == w->cur || w->head->next == w->cur) {
125 // no point in moving a job
126 return;
127 }
128
129 j = w->head->jlist.fnext;
130 if (!j || j == &w->head->jlist) {
131 // head holds no jlist; can't happen
132 twarnx("head holds no jlist");
133 return;
134 }
135
136 if (!walresvmigrate(w, j)) {
137 // it will not fit, so we'll try again later
138 return;
139 }
140
141 filermjob(w->head, j);
142 w->nmig++;
143 walwrite(w, j);
144 }
145
146
147 static void
148 walcompact(Wal *w)
149 {
150 int r;
151
152 for (r=ratio(w); r>=2; r--) {
153 moveone(w);
154 }
155 }
156
157
158 static void
159 walsync(Wal *w)
160 {
161 int64 now;
162
163 now = nanoseconds();
164 if (w->wantsync && now >= w->lastsync+w->syncrate) {
165 w->lastsync = now;
166 if (fsync(w->cur->fd) == -1) {
167 twarn("fsync");
168 }
169 }
170 }
171
172
173 // Walwrite writes j to the log w (if w is enabled).
174 // On failure, walwrite disables w and returns 0; on success, it returns 1.
175 // Unlke walresv*, walwrite should never fail because of a full disk.
176 // If w is disabled, then walwrite takes no action and returns 1.
177 int
178 walwrite(Wal *w, job j)
179 {
180 int r = 0;
181
182 if (!w->use) return 1;
183 if (w->cur->resv > 0 || usenext(w)) {
184 if (j->file) {
185 r = filewrjobshort(w->cur, j);
186 } else {
187 r = filewrjobfull(w->cur, j);
188 }
189 }
190 if (!r) {
191 filewclose(w->cur);
192 w->use = 0;
193 }
194 w->nrec++;
195 return r;
196 }
197
198
199 void
200 walmaint(Wal *w)
201 {
202 if (w->use) {
203 if (!w->nocomp) {
204 walcompact(w);
205 }
206 walsync(w);
207 }
208 }
209
210
211 static int
212 makenextfile(Wal *w)
213 {
214 File *f;
215
216 f = new(File);
217 if (!f) {
218 twarnx("OOM");
219 return 0;
220 }
221
222 if (!fileinit(f, w, w->next)) {
223 free(f);
224 twarnx("OOM");
225 return 0;
226 }
227
228 filewopen(f);
229 if (!f->iswopen) {
230 free(f->path);
231 free(f);
232 return 0;
233 }
234
235 w->next++;
236 fileadd(f, w);
237 return 1;
238 }
239
240
241 static void
242 moveresv(File *to, File *from, int n)
243 {
244 from->resv -= n;
245 from->free += n;
246 to->resv += n;
247 to->free -= n;
248 }
249
250
251 static int
252 needfree(Wal *w, int n)
253 {
254 if (w->tail->free >= n) return n;
255 if (makenextfile(w)) return n;
256 return 0;
257 }
258
259
260 // Ensures:
261 // 1. b->resv is congruent to n (mod z).
262 // 2. x->resv is congruent to 0 (mod z) for each future file x.
263 // Assumes (and preserves) that b->resv >= n.
264 // Reserved space is conserved (neither created nor destroyed);
265 // we just move it around to preserve the invariant.
266 // We might have to allocate a new file.
267 // Returns 1 on success, otherwise 0. If there was a failure,
268 // w->tail is not updated.
269 static int
270 balancerest(Wal *w, File *b, int n)
271 {
272 int rest, c, r;
273 static const int z = sizeof(int) + sizeof(Jobrec);
274
275 if (!b) return 1;
276
277 rest = b->resv - n;
278 r = rest % z;
279 if (r == 0) return balancerest(w, b->next, 0);
280
281 c = z - r;
282 if (w->tail->resv >= c && b->free >= c) {
283 moveresv(b, w->tail, c);
284 return balancerest(w, b->next, 0);
285 }
286
287 if (needfree(w, r) != r) {
288 twarnx("needfree");
289 return 0;
290 }
291 moveresv(w->tail, b, r);
292 return balancerest(w, b->next, 0);
293 }
294
295
296 // Ensures:
297 // 1. w->cur->resv >= n.
298 // 2. w->cur->resv is congruent to n (mod z).
299 // 3. x->resv is congruent to 0 (mod z) for each future file x.
300 // (where z is the size of a delete record in the wal).
301 // Reserved space is conserved (neither created nor destroyed);
302 // we just move it around to preserve the invariant.
303 // We might have to allocate a new file.
304 // Returns 1 on success, otherwise 0. If there was a failure,
305 // w->tail is not updated.
306 static int
307 balance(Wal *w, int n)
308 {
309 int r;
310
311 // Invariant 1
312 // (this loop will run at most once)
313 while (w->cur->resv < n) {
314 int m = w->cur->resv;
315
316 r = needfree(w, m);
317 if (r != m) {
318 twarnx("needfree");
319 return 0;
320 }
321
322 moveresv(w->tail, w->cur, m);
323 usenext(w);
324 }
325
326 // Invariants 2 and 3
327 return balancerest(w, w->cur, n);
328 }
329
330
331 // Returns the number of bytes successfully reserved: either 0 or n.
332 static int
333 reserve(Wal *w, int n)
334 {
335 int r;
336
337 // return value must be nonzero but is otherwise ignored
338 if (!w->use) return 1;
339
340 if (w->cur->free >= n) {
341 w->cur->free -= n;
342 w->cur->resv += n;
343 w->resv += n;
344 return n;
345 }
346
347 r = needfree(w, n);
348 if (r != n) {
349 twarnx("needfree");
350 return 0;
351 }
352
353 w->tail->free -= n;
354 w->tail->resv += n;
355 w->resv += n;
356 if (!balance(w, n)) {
357 // error; undo the reservation
358 w->resv -= n;
359 w->tail->resv -= n;
360 w->tail->free += n;
361 return 0;
362 }
363
364 return n;
365 }
366
367
368 // Returns the number of bytes reserved or 0 on error.
369 int
370 walresvput(Wal *w, job j)
371 {
372 int z = 0;
373
374 // reserve space for the initial job record
375 z += sizeof(int);
376 z += strlen(j->tube->name);
377 z += sizeof(Jobrec);
378 z += j->r.body_size;
379
380 // plus space for a delete to come later
381 z += sizeof(int);
382 z += sizeof(Jobrec);
383
384 return reserve(w, z);
385 }
386
387
388 // Returns the number of bytes reserved or 0 on error.
389 int
390 walresvupdate(Wal *w, job j)
391 {
392 int z = 0;
393
394 z +=sizeof(int);
395 z +=sizeof(Jobrec);
396 return reserve(w, z);
397 }
398
399
400 // Returns the number of locks acquired: either 0 or 1.
401 int
402 waldirlock(Wal *w)
403 {
404 int r;
405 int fd;
406 struct flock lk;
407 char path[PATH_MAX];
408
409 r = snprintf(path, PATH_MAX, "%s/lock", w->dir);
410 if (r > PATH_MAX) {
411 twarnx("path too long: %s/lock", w->dir);
412 return 0;
413 }
414
415 fd = open(path, O_WRONLY|O_CREAT, 0600);
416 if (fd == -1) {
417 twarn("open");
418 return 0;
419 }
420
421 lk.l_type = F_WRLCK;
422 lk.l_whence = SEEK_SET;
423 lk.l_start = 0;
424 lk.l_len = 0;
425 r = fcntl(fd, F_SETLK, &lk);
426 if (r) {
427 twarn("fcntl");
428 return 0;
429 }
430
431 // intentionally leak fd, since we never want to close it
432 // and we'll never need it again
433 return 1;
434 }
435
436
437 void
438 walread(Wal *w, job list, int min, int max)
439 {
440 File *f;
441 int i, fd;
442 int err = 0;
443
444 for (i = min; i < w->next; i++) {
445 f = new(File);
446 if (!f) {
447 twarnx("OOM");
448 exit(1);
449 }
450
451 if (!fileinit(f, w, i)) {
452 free(f);
453 twarnx("OOM");
454 exit(1);
455 }
456
457 fd = open(f->path, O_RDONLY);
458 if (fd < 0) {
459 twarn("%s", f->path);
460 free(f->path);
461 free(f);
462 continue;
463 }
464
465 f->fd = fd;
466 fileadd(f, w);
467 err |= fileread(f, list);
468 close(fd);
469 }
470
471 if (err) {
472 warnx("Errors reading one or more WAL files.");
473 warnx("Continuing. You may be missing data.");
474 }
475 }
476
477
478 void
479 walinit(Wal *w, job list)
480 {
481 int min;
482
483 min = walscandir(w);
484 walread(w, list, min, w->next);
485
486 // first writable file
487 if (!makenextfile(w)) {
488 twarnx("makenextfile");
489 exit(1);
490 }
491
492 w->cur = w->tail;
493 }