threadMain.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226
  1. #ident "ldclt @(#)threadMain.c 1.40 01/05/04"
  2. /** BEGIN COPYRIGHT BLOCK
  3. * This Program is free software; you can redistribute it and/or modify it under
  4. * the terms of the GNU General Public License as published by the Free Software
  5. * Foundation; version 2 of the License.
  6. *
  7. * This Program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  10. *
  11. * You should have received a copy of the GNU General Public License along with
  12. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  13. * Place, Suite 330, Boston, MA 02111-1307 USA.
  14. *
  15. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  16. * right to link the code of this Program with code not covered under the GNU
  17. * General Public License ("Non-GPL Code") and to distribute linked combinations
  18. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  19. * permitted under this exception must only link to the code of this Program
  20. * through those well defined interfaces identified in the file named EXCEPTION
  21. * found in the source code files (the "Approved Interfaces"). The files of
  22. * Non-GPL Code may instantiate templates or use macros or inline functions from
  23. * the Approved Interfaces without causing the resulting work to be covered by
  24. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  25. * additions to the list of Approved Interfaces. You must obey the GNU General
  26. * Public License in all respects for all of the Program code and other code used
  27. * in conjunction with the Program except the Non-GPL Code covered by this
  28. * exception. If you modify this file, you may extend this exception to your
  29. * version of the file, but you are not obligated to do so. If you do not wish to
  30. * provide this exception without modification, you must delete this exception
  31. * statement from your version and license this file solely under the GPL without
  32. * exception.
  33. *
  34. *
  35. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  36. * Copyright (C) 2006 Red Hat, Inc.
  37. * All rights reserved.
  38. * END COPYRIGHT BLOCK **/
  39. #ifdef HAVE_CONFIG_H
  40. # include <config.h>
  41. #endif
  42. /*
  43. FILE : threadMain.c
  44. AUTHOR : Jean-Luc SCHWING
  45. VERSION : 1.0
  46. DATE : 04 December 1998
  47. DESCRIPTION :
  48. This file implements the main/core part of the
  49. threads. The ldap part is in another source file.
  50. LOCAL : None.
  51. HISTORY :
  52. ---------+--------------+------------------------------------------------------
  53. dd/mm/yy | Author | Comments
  54. ---------+--------------+------------------------------------------------------
  55. 04/12/98 | JL Schwing | Creation
  56. ---------+--------------+------------------------------------------------------
  57. 10/12/98 | JL Schwing | 1.2 : Add nb of errors statistics.
  58. ---------+--------------+------------------------------------------------------
  59. 10/12/98 | JL Schwing | 1.3 : Implement asynchronous mode.
  60. ---------+--------------+------------------------------------------------------
  61. 11/12/98 | JL Schwing | 1.4 : Implement max errors threshold.
  62. | fflush(stdout) after each printf.
  63. ---------+--------------+------------------------------------------------------
  64. 14/12/98 | JL Schwing | 1.5 : Implement "-e close".
  65. | Add "thread is dead" message.
  66. ---------+--------------+------------------------------------------------------
  67. 16/12/98 | JL Schwing | 1.6 : Implement "-e add" and "-e delete".
  68. ---------+--------------+------------------------------------------------------
  69. 23/12/98 | JL Schwing | 1.7 : bug fix - crash in msgIdDel().
  70. ---------+--------------+------------------------------------------------------
  71. 28/12/98 | JL Schwing | 1.8 : Add tag asyncHit.
  72. ---------+--------------+------------------------------------------------------
  73. 13/01/99 | JL Schwing | 1.9 : Implement "-e string".
  74. ---------+--------------+------------------------------------------------------
  75. 18/01/99 | JL Schwing | 1.10: Implement "-e randombase".
  76. ---------+--------------+------------------------------------------------------
  77. 21/01/99 | JL Schwing | 1.11: Implement "-e ascii".
  78. ---------+--------------+------------------------------------------------------
  79. 26/02/99 | JL Schwing | 1.12: Improve strict ascii: reject more characters.
  80. ---------+--------------+------------------------------------------------------
  81. 26/02/99 | JL Schwing | 1.13: Quote (aka \) characters rather than reject.
  82. ---------+--------------+------------------------------------------------------
  83. 04/05/99 | JL Schwing | 1.14: Modify msgId*() to memorize attribs as well.
  84. ---------+--------------+------------------------------------------------------
  85. 19/05/99 | JL Schwing | 1.15: Implement "-e rename".
  86. | Exit the thread if status==DEAD
  87. ---------+--------------+------------------------------------------------------
  88. 28/05/99 | JL Schwing | 1.16: Add new option -W (wait).
  89. ---------+--------------+------------------------------------------------------
  90. 06/03/00 | JL Schwing | 1.17: Test malloc() return value.
  91. ---------+--------------+------------------------------------------------------
  92. 18/08/00 | JL Schwing | 1.18: Print begin and end dates.
  93. ---------+--------------+------------------------------------------------------
  94. 25/08/00 | JL Schwing | 1.19: Implement consistent exit status...
  95. | Fix some old legacy code.
  96. ---------+--------------+------------------------------------------------------
  97. 14/11/00 | JL Schwing | 1.20: Will now use utils.c functions.
  98. ---------+--------------+------------------------------------------------------
  99. 17/11/00 | JL Schwing | 1.21: Implement "-e smoothshutdown".
  100. | Add new functions setThreadStatus() getThreadStatus().
  101. ---------+--------------+------------------------------------------------------
  102. 21/11/00 | JL Schwing | 1.22: Implement "-e attreplace=name:mask"
  103. ---------+--------------+------------------------------------------------------
  104. 29/11/00 | JL Schwing | 1.23: Port on NT 4.
  105. ---------+--------------+------------------------------------------------------
  106. 01/12/00 | JL Schwing | 1.24: Port on Linux.
  107. ---------+--------------+------------------------------------------------------
  108. 15/12/00 | JL Schwing | 1.25: Add more trace in VERY_VERBOSE mode.
  109. ---------+--------------+------------------------------------------------------
  110. 18/12/00 | JL Schwing | 1.26: Add new exit status EXIT_INIT.
  111. ---------+--------------+------------------------------------------------------
  112. 05/01/01 | JL Schwing | 1.27: Implement "-e randombinddn" and associated
  113. | "-e randombinddnlow/high"
  114. ---------+--------------+------------------------------------------------------
  115. 08/01/01 | JL Schwing | 1.28: Implement "-e scalab01".
  116. ---------+--------------+------------------------------------------------------
  117. 12/01/01 | JL Schwing | 1.29: Include scalab01.h
  118. ---------+--------------+------------------------------------------------------
  119. 05/03/01 | JL Schwing | 1.30: Bug fix - crash SIGSEGV if no binDN provided.
  120. ---------+--------------+------------------------------------------------------
  121. 14/03/01 | JL Schwing | 1.31: Implement "-e commoncounter"
  122. | Add new function incrementCommonCounter().
  123. ---------+--------------+------------------------------------------------------
  124. 14/03/01 | JL Schwing | 1.32: Implement "-e dontsleeponserverdown".
  125. ---------+--------------+------------------------------------------------------
  126. 15/03/01 | JL Schwing | 1.33: Implement "-e randomattrlist=name:name:name"
  127. | Add new function selectRandomAttrList().
  128. ---------+--------------+------------------------------------------------------
  129. 19/03/01 | JL Schwing | 1.34: Implement "-e genldif=filename"
  130. ---------+--------------+------------------------------------------------------
  131. 23/03/01 | JL Schwing | 1.35: Implements "-e rdn=value".
  132. ---------+--------------+------------------------------------------------------
  133. 28/03/01 | JL Schwing | 1.36: Support -e commoncounter with -e rdn/object
  134. | Add new function incrementCommonCounterObject().
  135. ---------+--------------+------------------------------------------------------
  136. 02/04/01 | JL Schwing | 1.37: Bug fix : large files support for -e genldif.
  137. ---------+--------------+------------------------------------------------------
  138. 11/04/01 | JL Schwing | 1.38: Implement [INCRFROMFILE<NOLOOP>(myfile)]
  139. ---------+--------------+------------------------------------------------------
  140. 03/05/01 | JL Schwing | 1.39: Implement -e randombinddnfromfile=filename.
  141. ---------+--------------+------------------------------------------------------
  142. 04/05/01 | JL Schwing | 1.40: Implement -e bindonly.
  143. ---------+--------------+------------------------------------------------------
  144. */
  145. #include <stdio.h> /* printf(), etc... */
  146. #include <string.h> /* strerror(), etc... */
  147. #include <stdlib.h> /* exit(), etc... */
  148. #include <ctype.h> /* isascii(), etc... */
  149. #include <errno.h> /* errno, etc... */ /*JLS 06-03-00*/
  150. #include <lber.h> /* ldap C-API BER declarations */
  151. #include <ldap.h> /* ldap C-API declarations */
  152. #ifndef _WIN32 /*JLS 29-11-00*/
  153. #include <unistd.h> /* close(), etc... */
  154. #include <pthread.h> /* pthreads(), etc... */
  155. #include <signal.h> /* sigfillset(), etc... */
  156. #endif /*JLS 29-11-00*/
  157. #include "port.h" /* Portability definitions */ /*JLS 29-11-00*/
  158. #include "ldclt.h" /* This tool's include file */
  159. #include "utils.h" /* Utilities functions */ /*JLS 14-11-00*/
  160. #include "scalab01.h" /* Scalab01 specific */ /*JLS 12-01-01*/
  161. /* New */ /*JLS 15-03-01*/
  162. /* ****************************************************************************
  163. FUNCTION : selectRandomAttrList
  164. PURPOSE : Select a random attr list.
  165. INPUT : tttctx = this thread context
  166. OUTPUT : None.
  167. RETURN : The random list.
  168. DESCRIPTION :
  169. *****************************************************************************/
  170. char **
  171. selectRandomAttrList (
  172. thread_context *tttctx)
  173. {
  174. tttctx->attrlist[0] = mctx.attrlist[rndlim(0,mctx.attrlistNb-1)];
  175. return (tttctx->attrlist);
  176. }
  177. /* ****************************************************************************
  178. FUNCTION : randomString
  179. PURPOSE : Return a random string, of length nbDigits.
  180. The string is returned in tttctx->buf2.
  181. INPUT : tttctx = thread context.
  182. nbDigits = number of digits required.
  183. OUTPUT : None.
  184. RETURN : -1 if error, 0 else.
  185. DESCRIPTION :
  186. *****************************************************************************/
  187. int
  188. randomString (
  189. thread_context *tttctx,
  190. int nbDigits)
  191. {
  192. rndstr (tttctx->buf2, nbDigits); /*JLS 14-11-00*/
  193. return (0);
  194. }
  195. /* New */ /*JLS 28-03-01*/
  196. /* ****************************************************************************
  197. FUNCTION : incrementCommonCounterObject
  198. PURPOSE : Purpose of the fct
  199. INPUT : tttctx = thread context
  200. field = field to process
  201. OUTPUT : None.
  202. RETURN : -1 if error or end of loop (no_loop), new value else.
  203. DESCRIPTION :
  204. *****************************************************************************/
  205. int
  206. incrementCommonCounterObject (
  207. thread_context *tttctx,
  208. vers_field *field)
  209. {
  210. int ret; /* Return value */
  211. int val; /* New value */
  212. /*
  213. * Get mutex
  214. */
  215. if ((ret = ldclt_mutex_lock (&(field->cnt_mutex))) != 0)
  216. {
  217. fprintf (stderr, "ldclt[%d]: %s: cannot mutex_lock(field->cnt_mutex), error=%d (%s)\n",
  218. mctx.pid, tttctx->thrdId, ret, strerror (ret));
  219. fflush (stderr);
  220. return (-1);
  221. }
  222. /*
  223. * Compute next value
  224. */
  225. switch (field->how)
  226. {
  227. case HOW_INCR_FROM_FILE:
  228. case HOW_INCR_NB:
  229. if (field->cnt <= field->high) /* Limit not reached */
  230. {
  231. val = field->cnt;
  232. field->cnt++;
  233. }
  234. else
  235. {
  236. val = field->low;
  237. field->cnt = field->low + 1;
  238. }
  239. break;
  240. case HOW_INCR_FROM_FILE_NL:
  241. case HOW_INCR_NB_NOLOOP:
  242. if (field->cnt <= field->high) /* Limit not reached */
  243. {
  244. val = field->cnt;
  245. field->cnt++;
  246. }
  247. else
  248. val = -1; /* Exit thread */
  249. break;
  250. default:
  251. printf ("ldclt[%d]: %s: Illegal how=%d in incrementCommonCounterObject()\n",
  252. mctx.pid, tttctx->thrdId, field->how);
  253. val = -1;
  254. break;
  255. }
  256. /*
  257. * Free mutex
  258. */
  259. if ((ret = ldclt_mutex_unlock (&(field->cnt_mutex))) != 0)
  260. {
  261. fprintf(stderr,"ldclt[%d]: %s: cannot mutex_unlock(field->cnt_mutex), error=%d (%s)\n",
  262. mctx.pid, tttctx->thrdId, ret, strerror (ret));
  263. fflush (stderr);
  264. return (-1);
  265. }
  266. /*
  267. * Maybe a message to print ?
  268. */
  269. if (val < 0)
  270. printf ("ldclt[%d]: %s: Hit top incrementeal value\n", mctx.pid, tttctx->thrdId);
  271. return (val);
  272. }
  273. /* New */ /*JLS 14-03-01*/
  274. /* ****************************************************************************
  275. FUNCTION : incrementCommonCounter
  276. PURPOSE : Purpose of the fct
  277. INPUT : tttctx = thread context
  278. OUTPUT : None.
  279. RETURN : -1 if error or end of loop (no_loop), new value else.
  280. DESCRIPTION :
  281. *****************************************************************************/
  282. int
  283. incrementCommonCounter (
  284. thread_context *tttctx)
  285. {
  286. int ret; /* Return value */
  287. int val; /* New value */
  288. /*
  289. * Get mutex
  290. */
  291. if ((ret = ldclt_mutex_lock (&(mctx.lastVal_mutex))) != 0)
  292. {
  293. fprintf (stderr, "ldclt[%d]: T%03d: cannot mutex_lock(lastVal_mutex), error=%d (%s)\n",
  294. mctx.pid, tttctx->thrdNum, ret, strerror (ret));
  295. fflush (stderr);
  296. return (-1);
  297. }
  298. /*
  299. * Compute next value
  300. */
  301. if ((mctx.mode & NOLOOP) && (mctx.lastVal == mctx.randomHigh))
  302. val = -1;
  303. else
  304. {
  305. mctx.lastVal++;
  306. if (mctx.lastVal > mctx.randomHigh)
  307. {
  308. if (mctx.mode & NOLOOP)
  309. val = -1;
  310. else
  311. mctx.lastVal = mctx.randomLow;
  312. }
  313. val = mctx.lastVal;
  314. }
  315. /*
  316. * Free mutex
  317. */
  318. if ((ret = ldclt_mutex_unlock (&(mctx.lastVal_mutex))) != 0)
  319. {
  320. fprintf(stderr,"ldclt[%d]: T%03d: cannot mutex_unlock(lastVal_mutex), error=%d (%s)\n",
  321. mctx.pid, tttctx->thrdNum, ret, strerror (ret));
  322. fflush (stderr);
  323. return (-1);
  324. }
  325. /*
  326. * Maybe a message to print ?
  327. */
  328. if (val < 0)
  329. printf ("ldclt[%d]: T%03d: Hit top incrementeal value\n", mctx.pid, tttctx->thrdNum);
  330. return (val);
  331. }
  332. /* ****************************************************************************
  333. FUNCTION : incrementNbOpers
  334. PURPOSE : Increment the counters tttctx->nbOpers and
  335. tttctx->totOpers of the given thread.
  336. INPUT : tttctx = thread context.
  337. OUTPUT : None.
  338. RETURN : -1 if error, 0 else.
  339. DESCRIPTION :
  340. *****************************************************************************/
  341. int
  342. incrementNbOpers (
  343. thread_context *tttctx)
  344. {
  345. int ret; /* Return value */
  346. /*
  347. * Get mutex
  348. */
  349. if ((ret = ldclt_mutex_lock (&(tttctx->nbOpers_mutex))) != 0)
  350. {
  351. fprintf (stderr, "ldclt[%d]: T%03d: cannot mutex_lock(), error=%d (%s)\n",
  352. mctx.pid, tttctx->thrdNum, ret, strerror (ret));
  353. fflush (stderr);
  354. return (-1);
  355. }
  356. /*
  357. * Increment counter
  358. */
  359. tttctx->nbOpers++;
  360. /*
  361. * Free mutex
  362. */
  363. if ((ret = ldclt_mutex_unlock (&(tttctx->nbOpers_mutex))) != 0)
  364. {
  365. fprintf (stderr, "ldclt[%d]: T%03d: cannot mutex_unlock(), error=%d (%s)\n",
  366. mctx.pid, tttctx->thrdNum, ret, strerror (ret));
  367. fflush (stderr);
  368. return (-1);
  369. }
  370. /*
  371. * Increment total and check if max value reached
  372. */
  373. tttctx->totOpers++;
  374. if(tttctx->totalReq > -1) {
  375. if (tttctx->totOpers >= tttctx->totalReq) {
  376. if (setThreadStatus(tttctx, MUST_SHUTDOWN) < 0) {
  377. tttctx->status = DEAD; /* Force thread to die! */
  378. }
  379. }
  380. }
  381. return (0);
  382. }
  383. /* ****************************************************************************
  384. FUNCTION : ignoreError
  385. PURPOSE : Returns true or false depending on the given error
  386. should be ignored or not (option -I).
  387. We will sleep() if an error about server down is to be
  388. ignored.
  389. INPUT : err = error number
  390. OUTPUT : None.
  391. RETURN : 1 if should be ignored, 0 else.
  392. DESCRIPTION :
  393. *****************************************************************************/
  394. int
  395. ignoreError (
  396. int err)
  397. {
  398. int i;
  399. for (i=0 ; i<mctx.ignErrNb ; i++)
  400. if (mctx.ignErr[i] == err)
  401. { /*JLS 14-03-01*/
  402. if ((!(mctx.mode & DONT_SLEEP_DOWN)) && /*JLS 14-03-01*/
  403. ((err == LDAP_SERVER_DOWN) || /*JLS 14-03-01*/
  404. (err == LDAP_CONNECT_ERROR))) /*JLS 14-03-01*/
  405. ldclt_sleep (1); /*JLS 14-03-01*/
  406. return (1);
  407. } /*JLS 14-03-01*/
  408. return (0);
  409. }
  410. /* ****************************************************************************
  411. FUNCTION : addErrorStat
  412. PURPOSE : Add the given error number to the statistics.
  413. INPUT : err = error number
  414. OUTPUT : None.
  415. RETURN : -1 if error, 0 else.
  416. DESCRIPTION :
  417. *****************************************************************************/
  418. int
  419. addErrorStat (
  420. int err)
  421. {
  422. int ret; /* Return value */
  423. /*
  424. * Get mutex
  425. */
  426. if ((ret = ldclt_mutex_lock (&(mctx.errors_mutex))) != 0)
  427. {
  428. fprintf (stderr,
  429. "ldclt[%d]: Cannot mutex_lock(errors_mutex), error=%d (%s)\n",
  430. mctx.pid, ret, strerror (ret));
  431. fflush (stderr);
  432. return (-1);
  433. }
  434. /*
  435. * Update the counters
  436. */
  437. if ((err <= 0) || (err >= MAX_ERROR_NB))
  438. {
  439. fprintf (stderr, "ldclt[%d]: Illegal error number %d\n", mctx.pid, err);
  440. fflush (stderr);
  441. mctx.errorsBad++;
  442. }
  443. else
  444. mctx.errors[err]++;
  445. /*
  446. * Release the mutex
  447. */
  448. if ((ret = ldclt_mutex_unlock (&(mctx.errors_mutex))) != 0)
  449. {
  450. fprintf (stderr,
  451. "ldclt[%d]: Cannot mutex_unlock(errors_mutex), error=%d (%s)\n",
  452. mctx.pid, ret, strerror (ret));
  453. fflush (stderr);
  454. return (-1);
  455. }
  456. /*
  457. * Maybe we should ignore this error ?
  458. */
  459. if (!(ignoreError (err)))
  460. {
  461. /*
  462. * Ok, we should not ignore this error...
  463. * Maybe the limit is reached ?
  464. */
  465. if ((err <= 0) || (err >= MAX_ERROR_NB))
  466. {
  467. if (mctx.errorsBad > mctx.maxErrors)
  468. {
  469. printf ("ldclt[%d]: Max error limit reached - exiting.\n", mctx.pid);
  470. (void) printGlobalStatistics(); /*JLS 25-08-00*/
  471. fflush (stdout);
  472. ldclt_sleep (5);
  473. ldcltExit (EXIT_MAX_ERRORS); /*JLS 25-08-00*/
  474. }
  475. }
  476. else
  477. if (mctx.errors[err] > mctx.maxErrors)
  478. {
  479. printf ("ldclt[%d]: Max error limit reached - exiting.\n", mctx.pid);
  480. (void) printGlobalStatistics(); /*JLS 25-08-00*/
  481. fflush (stdout);
  482. ldclt_sleep (5);
  483. ldcltExit (EXIT_MAX_ERRORS); /*JLS 25-08-00*/
  484. }
  485. }
  486. /*
  487. * Normal end
  488. */
  489. return (0);
  490. }
  491. /* ****************************************************************************
  492. FUNCTION : msgIdAdd
  493. PURPOSE : Add a new message id to the pending ones.
  494. INPUT : tttctx = thread's context.
  495. msgid = message id.
  496. str = free string.
  497. dn = dn of the entry
  498. attribs = attributes
  499. OUTPUT : None.
  500. RETURN : -1 if error, 0 else.
  501. DESCRIPTION :
  502. *****************************************************************************/
  503. int
  504. msgIdAdd (
  505. thread_context *tttctx,
  506. int msgid,
  507. char *str,
  508. char *dn,
  509. LDAPMod **attribs)
  510. {
  511. if (mctx.mode & VERY_VERBOSE)
  512. printf ("ldclt[%d]: T%03d: msgIdAdd (%d, %s)\n", mctx.pid, tttctx->thrdNum, msgid, str);
  513. /*
  514. * Add the new cell
  515. */
  516. if (tttctx->firstMsgId == NULL)
  517. {
  518. tttctx->firstMsgId = (msgid_cell *) malloc (sizeof (msgid_cell));
  519. if (tttctx->firstMsgId == NULL) /*JLS 06-03-00*/
  520. { /*JLS 06-03-00*/
  521. printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->firstMsgId), error=%d (%s)\n",
  522. mctx.pid, tttctx->thrdNum, errno, strerror (errno));
  523. return (-1); /*JLS 06-03-00*/
  524. } /*JLS 06-03-00*/
  525. tttctx->lastMsgId = tttctx->firstMsgId;
  526. }
  527. else
  528. {
  529. tttctx->lastMsgId->next = (msgid_cell *) malloc (sizeof (msgid_cell));
  530. if (tttctx->lastMsgId->next == NULL) /*JLS 06-03-00*/
  531. { /*JLS 06-03-00*/
  532. printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->lastMsgId->next), error=%d (%s)\n",
  533. mctx.pid, tttctx->thrdNum, errno, strerror (errno));
  534. return (-1); /*JLS 06-03-00*/
  535. } /*JLS 06-03-00*/
  536. tttctx->lastMsgId = tttctx->lastMsgId->next;
  537. }
  538. /*
  539. * Memorize the information
  540. */
  541. tttctx->lastMsgId->next = NULL;
  542. tttctx->lastMsgId->msgid = msgid;
  543. strcpy (tttctx->lastMsgId->str, str);
  544. strcpy (tttctx->lastMsgId->dn, dn);
  545. tttctx->lastMsgId->attribs = attribs;
  546. return (0);
  547. }
  548. /* ****************************************************************************
  549. FUNCTION : msgIdAttribs
  550. PURPOSE : Found the requested message id in the pending list.
  551. INPUT : tttctx = thread's context
  552. msgid = message id
  553. OUTPUT : None
  554. RETURN : The associated attributes, or NULL.
  555. DESCRIPTION :
  556. *****************************************************************************/
  557. LDAPMod **
  558. msgIdAttribs (
  559. thread_context *tttctx,
  560. int msgid)
  561. {
  562. msgid_cell *pt;
  563. if (mctx.mode & VERY_VERBOSE)
  564. printf ("ldclt[%d]: T%03d: msgIdAttribs (%d)\n", mctx.pid, tttctx->thrdNum, msgid);
  565. for (pt = tttctx->firstMsgId ; pt != NULL ; pt = pt->next)
  566. if (pt->msgid == msgid)
  567. return (pt->attribs);
  568. return (NULL);
  569. }
  570. /* ****************************************************************************
  571. FUNCTION : msgIdDN
  572. PURPOSE : Found the requested message id in the pending list.
  573. INPUT : tttctx = thread's context
  574. msgid = message id
  575. OUTPUT : None
  576. RETURN : The associated DN, or NULL.
  577. DESCRIPTION :
  578. *****************************************************************************/
  579. char *
  580. msgIdDN (
  581. thread_context *tttctx,
  582. int msgid)
  583. {
  584. msgid_cell *pt;
  585. if (mctx.mode & VERY_VERBOSE)
  586. printf ("ldclt[%d]: T%03d: msgIdDN (%d)\n", mctx.pid, tttctx->thrdNum, msgid);
  587. for (pt = tttctx->firstMsgId ; pt != NULL ; pt = pt->next)
  588. if (pt->msgid == msgid)
  589. return (pt->dn);
  590. return (NULL);
  591. }
  592. /* ****************************************************************************
  593. FUNCTION : msgIdStr
  594. PURPOSE : Found the requested message id in the pending list.
  595. INPUT : tttctx = thread's context
  596. msgid = message id
  597. OUTPUT : None
  598. RETURN : The associated str, or an error message string.
  599. DESCRIPTION :
  600. *****************************************************************************/
  601. char *
  602. msgIdStr (
  603. thread_context *tttctx,
  604. int msgid)
  605. {
  606. msgid_cell *pt;
  607. if (mctx.mode & VERY_VERBOSE)
  608. printf ("ldclt[%d]: T%03d: msgIdStr (%d)\n", mctx.pid, tttctx->thrdNum, msgid);
  609. for (pt = tttctx->firstMsgId ; pt != NULL ; pt = pt->next)
  610. if (pt->msgid == msgid)
  611. return (pt->str);
  612. return ("Error: msgid not found");
  613. }
  614. /* ****************************************************************************
  615. FUNCTION : msgIdDel
  616. PURPOSE : Delete a message id from the pending ones.
  617. INPUT : tttctx = thread's context
  618. msgid = message id.
  619. freeAttr= true or false depending on freing the attribs
  620. OUTPUT : None.
  621. RETURN : -1 if not found, 0 else.
  622. DESCRIPTION :
  623. *****************************************************************************/
  624. int
  625. msgIdDel (
  626. thread_context *tttctx,
  627. int msgid,
  628. int freeAttr)
  629. {
  630. msgid_cell *pt; /* For the loop */
  631. msgid_cell *ptToFree; /* The cell to free */
  632. if (mctx.mode & VERY_VERBOSE)
  633. printf ("ldclt[%d]: T%03d: msgIdDel (%d)\n", mctx.pid, tttctx->thrdNum, msgid);
  634. /*
  635. * Make sure there is a list !
  636. */
  637. if (tttctx->firstMsgId != NULL)
  638. {
  639. /*
  640. * Maybe it is the first one ?
  641. */
  642. if (tttctx->firstMsgId->msgid == msgid)
  643. {
  644. ptToFree = tttctx->firstMsgId;
  645. tttctx->firstMsgId = tttctx->firstMsgId->next;
  646. if (tttctx->firstMsgId == NULL)
  647. tttctx->lastMsgId = NULL;
  648. free (ptToFree);
  649. return (0);
  650. }
  651. /*
  652. * Let's go through the whole list
  653. */
  654. for (pt = tttctx->firstMsgId ; pt->next != NULL ; pt = pt->next)
  655. if (pt->next->msgid == msgid)
  656. {
  657. /*
  658. * Be carrefull if it is the last element of the list
  659. */
  660. if (pt->next->next == NULL)
  661. tttctx->lastMsgId = pt;
  662. ptToFree = pt->next;
  663. pt->next = ptToFree->next;
  664. if (freeAttr)
  665. if (freeAttrib (ptToFree->attribs) < 0)
  666. return (-1);
  667. /*
  668. * Free the pointer itself
  669. */
  670. free (ptToFree);
  671. return (0);
  672. }
  673. }
  674. /*
  675. * Not found
  676. */
  677. printf ("ldclt[%d]: T%03d: message %d not found.\n", mctx.pid, tttctx->thrdNum, msgid);
  678. fflush (stdout);
  679. return (-1);
  680. }
  681. /* New function */ /*JLS 17-11-00*/
  682. /* ****************************************************************************
  683. FUNCTION : getThreadStatus
  684. PURPOSE : Get the value of a given thread's status.
  685. INPUT : tttctx = thread context
  686. OUTPUT : status = the thread's status
  687. RETURN : -1 if error, 0 else.
  688. DESCRIPTION :
  689. *****************************************************************************/
  690. int
  691. getThreadStatus (
  692. thread_context *tttctx,
  693. int *status)
  694. {
  695. int ret; /* Return code */
  696. if ((ret = ldclt_mutex_lock (&(tttctx->status_mutex))) != 0)
  697. {
  698. fprintf (stderr,
  699. "ldclt[%d]: Cannot mutex_lock(T%03d), error=%d (%s)\n",
  700. mctx.pid, tttctx->thrdNum, ret, strerror (ret));
  701. fprintf (stderr, "ldclt[%d]: Problem in getThreadStatus()\n", mctx.pid);
  702. fflush (stderr);
  703. return (-1);
  704. }
  705. *status = tttctx->status;
  706. if ((ret = ldclt_mutex_unlock (&(tttctx->status_mutex))) != 0)
  707. {
  708. fprintf (stderr,
  709. "ldclt[%d]: Cannot mutex_unlock(T%03d), error=%d (%s)\n",
  710. mctx.pid, tttctx->thrdNum, ret, strerror (ret));
  711. fprintf (stderr, "ldclt[%d]: Problem in getThreadStatus()\n", mctx.pid);
  712. fflush (stderr);
  713. return (-1);
  714. }
  715. return (0);
  716. }
  717. /* New function */ /*JLS 17-11-00*/
  718. /* ****************************************************************************
  719. FUNCTION : setThreadStatus
  720. PURPOSE : Set the value of a given thread's status.
  721. INPUT : tttctx = thread context
  722. status = new status
  723. OUTPUT : None.
  724. RETURN : -1 if error, 0 else.
  725. DESCRIPTION :
  726. *****************************************************************************/
  727. int
  728. setThreadStatus (
  729. thread_context *tttctx,
  730. int status)
  731. {
  732. int ret; /* Return code */
  733. if ((ret = ldclt_mutex_lock (&(tttctx->status_mutex))) != 0)
  734. {
  735. fprintf (stderr,
  736. "ldclt[%d]: Cannot mutex_lock(T%03d), error=%d (%s)\n",
  737. mctx.pid, tttctx->thrdNum, ret, strerror (ret));
  738. fprintf (stderr, "ldclt[%d]: Problem in setThreadStatus()\n", mctx.pid);
  739. fflush (stderr);
  740. return (-1);
  741. }
  742. tttctx->status = status;
  743. if ((ret = ldclt_mutex_unlock (&(tttctx->status_mutex))) != 0)
  744. {
  745. fprintf (stderr,
  746. "ldclt[%d]: Cannot mutex_unlock(T%03d), error=%d (%s)\n",
  747. mctx.pid, tttctx->thrdNum, ret, strerror (ret));
  748. fprintf (stderr, "ldclt[%d]: Problem in setThreadStatus()\n", mctx.pid);
  749. fflush (stderr);
  750. return (-1);
  751. }
  752. return (0);
  753. }
  754. /* ****************************************************************************
  755. FUNCTION : threadMain
  756. PURPOSE : This function is the main function of the client threads
  757. part of this tool.
  758. INPUT : arg = this thread's thread_context
  759. OUTPUT : None.
  760. RETURN : None.
  761. DESCRIPTION :
  762. *****************************************************************************/
  763. void *
  764. threadMain (
  765. void *arg)
  766. {
  767. thread_context *tttctx; /* This thread's context */
  768. int go = 1; /* Thread must continue */
  769. int status; /* Thread's status */ /*JLS 17-11-00*/
  770. /*
  771. * Initialization
  772. */
  773. tttctx = (thread_context *) arg;
  774. if (setThreadStatus (tttctx, CREATED) < 0) /*JLS 17-11-00*/
  775. { /*JLS 17-11-00*/
  776. tttctx->status = DEAD; /*JLS 17-11-00*/
  777. return NULL; /*JLS 17-11-00*/
  778. } /*JLS 17-11-00*/
  779. tttctx->asyncHit = 0;
  780. tttctx->binded = 0;
  781. tttctx->fd = -1;
  782. tttctx->lastVal = mctx.randomLow-1;
  783. tttctx->ldapCtx = NULL;
  784. tttctx->matcheddnp = NULL; /*JLS 15-12-00*/
  785. tttctx->nbOpers = 0;
  786. tttctx->totOpers = 0;
  787. tttctx->pendingNb = 0;
  788. tttctx->firstMsgId = NULL;
  789. tttctx->lastMsgId = NULL;
  790. /*
  791. * Don't forget the buffers !!
  792. * This should save time while redoing random values
  793. */
  794. if ((mctx.mode & NEED_FILTER) || (mctx.mod2 & M2_GENLDIF)) /*JLS 19-03-01*/
  795. {
  796. if (mctx.mod2 & M2_RDN_VALUE) /*JLS 23-03-01*/
  797. tttctx->bufFilter = (char *) malloc (MAX_FILTER); /*JLS 23-03-01*/
  798. else /*JLS 23-03-01*/
  799. { /*JLS 23-03-01*/
  800. /*
  801. * Variable filter ?
  802. */
  803. tttctx->bufFilter = (char *) malloc (strlen (mctx.filter) + 1);
  804. if (tttctx->bufFilter == NULL) /*JLS 06-03-00*/
  805. { /*JLS 06-03-00*/
  806. printf ("ldclt[%d]: %s: cannot malloc(tttctx->bufFilter), error=%d (%s)\n",
  807. mctx.pid, tttctx->thrdId, errno, strerror (errno));
  808. ldcltExit (EXIT_INIT); /*JLS 18-12-00*/
  809. } /*JLS 06-03-00*/
  810. if (!(mctx.mode & (RANDOM | INCREMENTAL)))
  811. strcpy (tttctx->bufFilter, mctx.filter);
  812. else
  813. {
  814. tttctx->startRandom = strlen (mctx.randomHead);
  815. strcpy (tttctx->bufFilter, mctx.randomHead);
  816. strcpy (&(tttctx->bufFilter[tttctx->startRandom+mctx.randomNbDigit]),
  817. mctx.randomTail);
  818. if (mctx.mode & VERY_VERBOSE)
  819. {
  820. printf ("ldclt[%d]: %s: startRandom = %d\n",
  821. mctx.pid, tttctx->thrdId, tttctx->startRandom);
  822. printf ("ldclt[%d]: %s: randomHead = \"%s\", randomTail = \"%s\"\n",
  823. mctx.pid, tttctx->thrdId, mctx.randomHead, mctx.randomTail);
  824. }
  825. }
  826. } /*JLS 23-03-01*/
  827. /*
  828. * Variable base DN ?
  829. */
  830. tttctx->bufBaseDN = (char *) malloc (strlen (mctx.baseDN) + 1);
  831. if (tttctx->bufBaseDN == NULL) /*JLS 06-03-00*/
  832. { /*JLS 06-03-00*/
  833. printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->bufBaseDN), error=%d (%s)\n",
  834. mctx.pid, tttctx->thrdNum, errno, strerror (errno));
  835. ldcltExit (EXIT_INIT); /*JLS 18-12-00*/
  836. } /*JLS 06-03-00*/
  837. if (!(mctx.mode & RANDOM_BASE))
  838. strcpy (tttctx->bufBaseDN, mctx.baseDN);
  839. else
  840. {
  841. tttctx->startBaseDN = strlen (mctx.baseDNHead);
  842. strcpy (tttctx->bufBaseDN, mctx.baseDNHead);
  843. strcpy (&(tttctx->bufBaseDN[tttctx->startBaseDN+mctx.baseDNNbDigit]),
  844. mctx.baseDNTail);
  845. }
  846. /*
  847. * Variable bind DN ?
  848. * Do not forget the random bind password below that is activated
  849. * at the same time as the random bind DN.
  850. */
  851. if (mctx.bindDN != NULL) /*JLS 05-03-01*/
  852. { /*JLS 05-03-01*/
  853. tttctx->bufBindDN = (char *) malloc (strlen (mctx.bindDN) + 1);
  854. if (tttctx->bufBindDN == NULL)
  855. {
  856. printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->bufBindDN), error=%d (%s)\n",
  857. mctx.pid, tttctx->thrdNum, errno, strerror (errno));
  858. ldcltExit (EXIT_INIT);
  859. }
  860. if (!(mctx.mode & RANDOM_BINDDN))
  861. strcpy (tttctx->bufBindDN, mctx.bindDN);
  862. else
  863. {
  864. tttctx->startBindDN = strlen (mctx.bindDNHead);
  865. strcpy (tttctx->bufBindDN, mctx.bindDNHead);
  866. strcpy (&(tttctx->bufBindDN[tttctx->startBindDN+mctx.bindDNNbDigit]),
  867. mctx.bindDNTail);
  868. }
  869. } /*JLS 05-03-01*/
  870. /*
  871. * Variable bind password ?
  872. * Remember that the random bind password feature is activated
  873. * by the same option as the random bind DN, but has here its own
  874. * code section for the ease of coding.
  875. */
  876. if (mctx.passwd != NULL) /*JLS 05-03-01*/
  877. { /*JLS 05-03-01*/
  878. tttctx->bufPasswd = (char *) malloc (strlen (mctx.passwd) + 1);
  879. if (tttctx->bufPasswd == NULL)
  880. {
  881. printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->bufPasswd), error=%d (%s)\n",
  882. mctx.pid, tttctx->thrdNum, errno, strerror (errno));
  883. ldcltExit (EXIT_INIT);
  884. }
  885. if (!(mctx.mode & RANDOM_BINDDN))
  886. strcpy (tttctx->bufPasswd, mctx.passwd);
  887. else
  888. {
  889. tttctx->startPasswd = strlen (mctx.passwdHead);
  890. strcpy (tttctx->bufPasswd, mctx.passwdHead);
  891. strcpy (&(tttctx->bufPasswd[tttctx->startPasswd+mctx.passwdNbDigit]),
  892. mctx.passwdTail);
  893. }
  894. }
  895. } /*JLS 05-03-01*/
  896. /*
  897. * Bind DN from a file ?
  898. * The trick (mctx.passwd = "foo bar"; ) is needed to
  899. * simplify the code, because in many places we check
  900. * if mctx.passwd exist before sending password.
  901. */
  902. if (mctx.mod2 & M2_RNDBINDFILE) /*JLS 03-05-01*/
  903. { /*JLS 03-05-01*/
  904. tttctx->bufBindDN = (char *) malloc (MAX_DN_LENGTH); /*JLS 03-05-01*/
  905. tttctx->bufPasswd = (char *) malloc (MAX_DN_LENGTH); /*JLS 03-05-01*/
  906. mctx.passwd = "foo bar"; /* trick... */ /*JLS 03-05-01*/
  907. } /*JLS 03-05-01*/
  908. /*
  909. * Variable Authid ?
  910. */
  911. if (mctx.sasl_authid != NULL)
  912. {
  913. tttctx->bufSaslAuthid = (char *) malloc (strlen (mctx.sasl_authid) + 1);
  914. if (tttctx->bufSaslAuthid == NULL)
  915. {
  916. printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->bufSaslAuthid), error=%d (%s)\n",
  917. mctx.pid, tttctx->thrdNum, errno, strerror (errno));
  918. ldcltExit (EXIT_INIT);
  919. }
  920. if (!(mctx.mod2 & M2_RANDOM_SASLAUTHID))
  921. strcpy (tttctx->bufSaslAuthid, mctx.sasl_authid);
  922. else
  923. {
  924. tttctx->startSaslAuthid = strlen (mctx.sasl_authid_head);
  925. strcpy (tttctx->bufSaslAuthid, mctx.sasl_authid_head);
  926. strcpy (&(tttctx->bufSaslAuthid[tttctx->startSaslAuthid+mctx.sasl_authid_nbdigit]),
  927. mctx.sasl_authid_tail);
  928. }
  929. }
  930. /*
  931. * Initiates the attribute replace buffers
  932. */
  933. if (mctx.mode & ATTR_REPLACE) /* New */ /*JLS 21-11-00*/
  934. {
  935. tttctx->bufAttrpl = (char *) malloc (strlen (mctx.attrpl) + 1);
  936. if (tttctx->bufAttrpl == NULL)
  937. {
  938. printf ("ldclt[%d]: T%03d: cannot malloc(tttctx->bufAttrpl), error=%d (%s)\n",
  939. mctx.pid, tttctx->thrdNum, errno, strerror (errno));
  940. ldcltExit (EXIT_INIT); /*JLS 18-12-00*/
  941. }
  942. tttctx->startAttrpl = strlen (mctx.attrplHead);
  943. strcpy (tttctx->bufAttrpl, mctx.attrplHead);
  944. strcpy (&(tttctx->bufAttrpl[tttctx->startAttrpl+mctx.attrplNbDigit]),
  945. mctx.attrplTail);
  946. }
  947. /*
  948. * We are ready to go !
  949. */
  950. status = RUNNING; /*JLS 17-11-00*/
  951. if (setThreadStatus (tttctx, RUNNING) < 0) /*JLS 17-11-00*/
  952. status = DEAD; /*JLS 17-11-00*/
  953. /*
  954. * Let's go !
  955. */
  956. while (go && (status != DEAD) && (status != MUST_SHUTDOWN)) /*JLS 17-11-00*/
  957. {
  958. if (mctx.waitSec > 0)
  959. { /*JLS 17-11-00*/
  960. ldclt_sleep (mctx.waitSec);
  961. /*
  962. * Maybe we should shutdown ?
  963. */
  964. if (getThreadStatus (tttctx, &status) < 0) /*JLS 17-11-00*/
  965. break; /*JLS 17-11-00*/
  966. if (status == MUST_SHUTDOWN) /*JLS 17-11-00*/
  967. break; /*JLS 17-11-00*/
  968. } /*JLS 17-11-00*/
  969. /*
  970. * Do a LDAP request
  971. */
  972. if (tttctx->mode & ADD_ENTRIES)
  973. if (doAddEntry (tttctx) < 0)
  974. {
  975. go = 0;
  976. continue;
  977. }
  978. if (tttctx->mode & ATTR_REPLACE) /*JLS 21-11-00*/
  979. if (doAttrReplace (tttctx) < 0) /*JLS 21-11-00*/
  980. { /*JLS 21-11-00*/
  981. go = 0; /*JLS 21-11-00*/
  982. continue; /*JLS 21-11-00*/
  983. } /*JLS 21-11-00*/
  984. if (tttctx->mode & DELETE_ENTRIES)
  985. if (doDeleteEntry (tttctx) < 0)
  986. {
  987. go = 0;
  988. continue;
  989. }
  990. if (mctx.mod2 & M2_BINDONLY) /*JLS 04-05-01*/
  991. if (doBindOnly (tttctx) < 0) /*JLS 04-05-01*/
  992. { /*JLS 04-05-01*/
  993. go = 0; /*JLS 04-05-01*/
  994. continue; /*JLS 04-05-01*/
  995. } /*JLS 04-05-01*/
  996. if (tttctx->mode & EXACT_SEARCH)
  997. if (doExactSearch (tttctx) < 0)
  998. {
  999. go = 0;
  1000. continue;
  1001. }
  1002. if (tttctx->mode & RENAME_ENTRIES)
  1003. if (doRename (tttctx) < 0)
  1004. {
  1005. go = 0;
  1006. continue;
  1007. }
  1008. /*
  1009. * Maybe a specific scenario ?
  1010. */
  1011. if (tttctx->mode & SCALAB01) /*JLS 08-01-01*/
  1012. if (doScalab01 (tttctx) < 0) /*JLS 08-01-01*/
  1013. { /*JLS 08-01-01*/
  1014. go = 0; /*JLS 08-01-01*/
  1015. continue; /*JLS 08-01-01*/
  1016. } /*JLS 08-01-01*/
  1017. /*
  1018. * Maybe genldif mode ?
  1019. */
  1020. if (mctx.mod2 & M2_GENLDIF) /*JLS 19-03-01*/
  1021. if (doGenldif (tttctx) < 0) /*JLS 19-03-01*/
  1022. { /*JLS 19-03-01*/
  1023. ldclt_flush_genldif(); /*JLS 02-04-01*/
  1024. go = 0; /*JLS 19-03-01*/
  1025. continue; /*JLS 19-03-01*/
  1026. } /*JLS 19-03-01*/
  1027. /*
  1028. * Check the thread's status
  1029. */
  1030. if (getThreadStatus (tttctx, &status) < 0) /*JLS 17-11-00*/
  1031. break; /*JLS 17-11-00*/
  1032. }
  1033. /*
  1034. * End of thread
  1035. */
  1036. /* [156984] once setting "DEAD", nothing should be done in the context */
  1037. /* moved the dead message above setThreadStatus(DEAD) */
  1038. printf ("ldclt[%d]: T%03d: thread is dead.\n", mctx.pid, tttctx->thrdNum);
  1039. fflush (stdout);
  1040. if (setThreadStatus (tttctx, DEAD) < 0) /*JLS 17-11-00*/
  1041. { /*JLS 17-11-00*/
  1042. ldclt_sleep (1); /*JLS 17-11-00*/
  1043. tttctx->status = DEAD; /* Force it !!! */ /*JLS 17-11-00*/
  1044. } /*JLS 17-11-00*/
  1045. return (arg);
  1046. }
  1047. /* End of file */