Jump to content
UBot Underground

Thread-Safe Deletion From A Global List


Recommended Posts

Hi there,

 

I'm trying to figure out how to handle proxies in my multithreaded bot.

 

Right now, there's a master list of search terms it uses, and a master list of proxies it pulls from. For the search terms it pulls, it's using standard threading and next list item, and for the proxy grabbing it uses a random proxy from the master list.

 

Everything works great for the  most part, but now I'm trying to figure out how to handle bad/blocked proxies.

 

I had originally tried copying a the global Master Proxy List to a local list inside the thread, pulling a random proxy from that list, trying to use it, and checking the results.

 

If it passed, great, it carries on.

 

If it fails, I want to have it pull that proxy from the master list so that other threads don't continually try to use bad proxies and slow the bot down.

 

I tried adding this code in (found in another thread, modified to use Local instead of Global since it's inside a thread):

 

set(#stopme, 0, "Local")

set(#pos, 0, "Local")

loop while($comparison(#stopme, "=", 0)) {

    if($comparison($list item(%masterProxyList, #pos), "=", #currentProxy)) {

        then {

            remove from list(%test, #pos)

            set(#stopme, 1, "Local")

        }

        else {

            increment(#pos)

        }

    }

}

 

However, if two threads fail with two different proxies simultaneously, the master list would be changed by one thread deleting the offending proxy before the other does, which would then mess up the position of 2nd bad proxy the bot is trying to delete, which results in either the bot deleting the wrong proxy or getting an out of bounds error (if it tries to delete the proxy from the 8th position when there's only 7 left after the other thread deletes, for example).

 

I'm trying to wrap my head around how to best tackle a thread-safe global list that threads can delete specified proxies from, and this is my best idea, but I may be barking up the wrong tree as far as execution goes.

 

Any ideas, thoughts, or code examples would be immensely helpful.

 

Thanks in advance for your time!

Link to post
Share on other sites
Awesome thank you, I have that plugin but I don't have any experience with thread locking and updating a global list so I think I'll need to go through that thread and hopefully someone has discussed using thread locking, as I'm not sure where to even start with that lol

 

Thank you for pointing me in the right direction!

 

Sent from my SAMSUNG-SM-N920A using Tapatalk

Link to post
Share on other sites

Awesome thank you, I have that plugin but I don't have any experience with thread locking and updating a global list so I think I'll need to go through that thread and hopefully someone has discussed using thread locking, as I'm not sure where to even start with that lol

 

Thank you for pointing me in the right direction!

 

Sent from my SAMSUNG-SM-N920A using Tapatalk

 

I haven't used that plugin much so you will have to test this but I believe all you need to do is use the lock command right before your thread safe operation then call unlock after it like this:

thread {
    comment("Do whatever you need in your thread.")
    divider
    plugin command("HeopasCustom.dll", "Heopas Thread Lock", "")
    comment("Thread safe operation goes here")
    plugin command("HeopasCustom.dll", "Heopas Thread Unlock")
}
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...