I need a program written in C that will work in Linux.
It needs to do several things.
- It will do a SELECT on a mysql database for 3 fields. server, request, and ID. It will then send a URL request to http://$server/$request/ and wait for the $server to respond, when it responds, it needs to insert the "results" in another table, associated with the ID.
That should be the simple part. Now, I need it to do queuing (spawning) and it should be able to do 10 spawns at any given time.
So, it will grab 10 rows in this queue table, send 10 URLs to the servers, wait for responses, and once it receives 1 response, it will go ahead and do another one.
It should NOT do anymore then 10 at any given time.
It needs to keep track of all of them because each spawn will have a different ID, where it will need to update the other table with the results.
All the configuration tags should be able to be put into the startup script. Example: ./queue -s 10 -t 20
-s would be how many spawns to do at any given time
-t would be how long to wait when it runs out of things in the queue.
So, for -t, let's say it continues to do a select, over and over, as spawns die off. Eventunally it's going to catch up to the table and not have anymore rows in the queue, so when there's no more rows in the table, it should wait 20 seconds (in my example) and then do another select to see if there's more in the queue.
Thanks.