Github user jburwell commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1765#discussion_r88391467
  
    --- Diff: 
plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ---
    @@ -100,36 +100,25 @@ protected SR createFileSR(final Connection conn, 
final String path) {
             PBD pbd = null;
     
             try {
    -            final String srname = hypervisorResource.getHost().getUuid() + 
path.trim();
    -
    -            final Set<SR> srs = SR.getByNameLabel(conn, srname);
    -
    -            if (srs != null && !srs.isEmpty()) {
    -                return srs.iterator().next();
    +            final String srname = path.trim();
    +            synchronized (srname.intern()) {
    +                final Set<SR> srs = SR.getByNameLabel(conn, srname);
    +                if (srs != null && !srs.isEmpty()) {
    +                    return srs.iterator().next();
    +                }
    +                final Map<String, String> smConfig = new HashMap<String, 
String>();
    +                final Host host = Host.getByUuid(conn, 
hypervisorResource.getHost().getUuid());
    +                final String uuid = UUID.randomUUID().toString();
    +                sr = SR.introduce(conn, uuid, srname, srname, "file", 
"file", false, smConfig);
    +                final PBD.Record record = new PBD.Record();
    +                record.host = host;
    +                record.SR = sr;
    +                smConfig.put("location", path);
    +                record.deviceConfig = smConfig;
    +                pbd = PBD.create(conn, record);
    +                pbd.plug(conn);
    +                sr.scan(conn);
    --- End diff --
    
    Some of the work in this `synchronized` block does not appear to need a 
lock to be successful.  Please consider refactoring to move that work out of 
this block to reduce the size of the critical section.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to