|
|
@@ -747,7 +747,7 @@ static bool read_modulus(const char *filename)
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-int controller_main(const char *modulus_file, unsigned short bindport)
|
|
|
+int controller_main(const Worklist &worklist, unsigned short bindport)
|
|
|
{
|
|
|
// Initialize the prng with some randomness from the kernel
|
|
|
unsigned char randbuf[1024];
|
|
|
@@ -757,10 +757,14 @@ int controller_main(const char *modulus_file, unsigned short bindport)
|
|
|
ZZ randzz = ZZFromBytes(randbuf, sizeof(randbuf));
|
|
|
SetSeed(randzz);
|
|
|
|
|
|
+ if (worklist.size() == 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
// Read the modulus and the factorization of its totient from the
|
|
|
// specified file
|
|
|
- if (!read_modulus(modulus_file)) {
|
|
|
- cerr << "Unable to read file " << modulus_file << "\n";
|
|
|
+ if (!read_modulus(worklist[0].first)) {
|
|
|
+ cerr << "Unable to read file " << worklist[0].first << "\n";
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
@@ -770,12 +774,12 @@ int controller_main(const char *modulus_file, unsigned short bindport)
|
|
|
unsigned short myport;
|
|
|
|
|
|
ctrlstate.listener = controller_create(evbase, bindport, &myip, &myport);
|
|
|
- struct in_addr myaddr = { myip };
|
|
|
#ifdef VERBOSE
|
|
|
+ struct in_addr myaddr = { myip };
|
|
|
printf("Bound to %s:%d\n", inet_ntoa(myaddr), ntohs(myport));
|
|
|
#endif
|
|
|
|
|
|
- ctrlstate.problems_remaining = 2;
|
|
|
+ ctrlstate.problems_remaining = worklist[0].second;
|
|
|
|
|
|
// Kick off the first problem to solve
|
|
|
generate_problem(evbase);
|