~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to client/drizzleslap.cc

  • Committer: Lee Bieber
  • Date: 2010-11-08 02:12:25 UTC
  • mfrom: (1912.1.2 build)
  • Revision ID: kalebral@gmail.com-20101108021225-7vfdp6cn81b8i1cx
Merge Brian - Cleanup counter_thread for slap, and remove the need to track the count of threads by doing a join to harvest.
Merge Andrew - fix bug 653240: drizzle command line client reads copious amounts of data into RAM before sending commands 
Merge Andrew - fix bug 672074: buffer overrun in LineBuffer

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
static char *shared_memory_base_name=0;
120
120
#endif
121
121
 
122
 
/* Global Thread counter */
123
 
uint32_t thread_counter;
124
 
boost::mutex counter_mutex;
125
 
boost::condition_variable_any count_threshhold;
126
 
 
127
122
client::Wakeup master_wakeup;
128
123
 
129
124
/* Global Thread timer */
384
379
 
385
380
  slap_close(con);
386
381
 
387
 
  {
388
 
    boost::mutex::scoped_lock scopedLock(counter_mutex);
389
 
    thread_counter--;
390
 
    count_threshhold.notify_one();
391
 
  }
392
 
 
393
382
  delete ctx;
394
383
}
395
384
 
1920
1909
  }
1921
1910
}
1922
1911
 
 
1912
typedef boost::shared_ptr<boost::thread> Thread;
 
1913
typedef std::vector <Thread> Threads;
1923
1914
static void run_scheduler(Stats *sptr, Statement **stmts, uint32_t concur, uint64_t limit)
1924
1915
{
1925
1916
  uint32_t real_concurrency;
1926
1917
  struct timeval start_time, end_time;
1927
1918
 
 
1919
  Threads threads;
 
1920
 
1928
1921
  {
1929
 
    boost::mutex::scoped_lock lock(counter_mutex);
1930
 
 
1931
1922
    OptionString *sql_type;
1932
 
    thread_counter= 0;
1933
1923
 
1934
1924
    master_wakeup.reset();
1935
1925
 
1966
1956
          real_concurrency++;
1967
1957
 
1968
1958
          /* now you create the thread */
1969
 
          boost::thread new_thread(boost::bind(&run_task, con));
1970
 
          thread_counter++;
 
1959
          Thread thread;
 
1960
          thread= Thread(new boost::thread(boost::bind(&run_task, con)));
 
1961
          threads.push_back(thread);
 
1962
 
1971
1963
        }
1972
1964
      }
1973
1965
    }
1983
1975
        timer_alarm= true;
1984
1976
      }
1985
1977
 
1986
 
      boost::thread new_thread(&timer_thread);
 
1978
      Thread thread;
 
1979
      thread= Thread(new boost::thread(&timer_thread));
 
1980
      threads.push_back(thread);
1987
1981
    }
1988
1982
  }
1989
1983
 
1994
1988
  /*
1995
1989
    We loop until we know that all children have cleaned up.
1996
1990
  */
 
1991
  for (Threads::iterator iter= threads.begin(); iter != threads.end(); iter++)
1997
1992
  {
1998
 
    boost::mutex::scoped_lock scopedLock(counter_mutex);
1999
 
    while (thread_counter)
2000
 
    {
2001
 
      boost::xtime xt; 
2002
 
      xtime_get(&xt, boost::TIME_UTC); 
2003
 
      xt.sec += 3;
2004
 
 
2005
 
      count_threshhold.timed_wait(scopedLock, xt);
2006
 
    }
 
1993
    (*iter)->join();
2007
1994
  }
2008
1995
 
2009
1996
  gettimeofday(&end_time, NULL);